如题

解决方案 »

  1.   


    假设你执行下面查询:
    select ename,empno,jog,sal
    from emp
    where sal between 2300 and 5600;
    需要花1分钟以上的时间(首先你的数据量很大);
    那么你就得在这个检索条件 sal 上建立索引。
    --还有其他很多原因,具体找本书看看吧!
      

  2.   

    Use the following guidelines for determining when to create an index:
    ■ Create an index if you frequently want to retrieve less than 15% of the rows in a
    large table. The percentage varies greatly according to the relative speed of a table
    scan and how the distribution of the row data in relation to the index key. The
    faster the table scan, the lower the percentage; the more clustered the row data, the
    higher the percentage.
    ■ To improve performance on joins of multiple tables, index columns used for joins.
    ■ Small tables do not require indexes. If a query is taking too long, then the table
    might have grown from small to large.
      

  3.   

    如果这张表需要进行大量的DML操作,则不宜在其上建索引:因为在进行DML操作时会需要更新索引,更新索引需要花时间,因此会降低系统的效率;但当一某张表是主要用来查询的或只有少量的DML操作则应建立索引。索引就好比一本书的目录能很快定位要找的内容。
      

  4.   

    不过索引会对UPDATE,DELETE时有影响哦,所以还是要看表适用情况,建立合理的索引
      

  5.   

    某个或几个字段经常出现在where条件里,这个或是这几个一般可以建个索引,但是有些条件值,只有0或1两个条件,就没必要了,如果是日期类型字段这样的,有必要建.