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