Establish the principle of indexing summary

https://www.cnblogs.com/garfieldcgf/p/6378690.html

https://www.cnblogs.com/xlhblogs/archive/2012/09/21/2696411.html

First, the filter is often used to record field.

1. primary key field, the system automatically creates the primary key indexes;

2. unique kye field, the system automatically creates a corresponding index;

3. foreign key constraints defined as a foreign key field;

4. The connection field of the table to the query;

The sort often used (order by field) the reference field;


II. Index takes up disk space, create unnecessary indexes only a waste.

III. Creating index must consider the mode of operation of the data.

1. Content that rarely change, often queries, create several multi-index do not care for it;

2. regular, routine with a variable table, you need to carefully indeed necessary to create an index;


IV. The difference between the primary key and a unique key
1. As a Primary Key Domain / field group can not be null. The Unique Key can.
2. In a table can have a Primary Key, and a plurality of Unique Key may exist simultaneously.
Larger differences in the logic design, typically used as a Primary Key record identification logic design, which is provided
Primary Key originally intended, and Unique Key only to ensure the uniqueness of domain / domain group.


Fifth, the composite index and a single index

  Refers to a composite index multi-joint index field, often in combination with these fields we need to re-query the query conditions
  unique index ID is mainly used primary key index, stored in correspondence with the physical structure of the structural order

Such as: create index idx on tbl (a  , b)
 press a sort, b a same sort, so when you check when a or ab,
. Can be utilized to check this index b but only when you index help your little probably can find a jump.

Guess you like

Origin www.cnblogs.com/lukelook/p/11248046.html