何時需索引?
1、The column is used frequently in the where clause or join condition.
2、The column contains a wide range of values.
3、The column contains a large number of null values.
4、Two or more culumn are frequently used together in a where clause or join condition.
5、The table is large and most queries are expected to retrieve less than 2-4% of the rows.
何時不需索引?
1、The table is small.
2、The columns are not often used as a condition in the query.
3、Most queries are expected to retrieve more than 2-4% of the rows.
4、The table is updated frequently.
Note:若where條件包含is not null即使建立index依然會造成Full table scan。