Mysql determine whether the columns you want to add standard index

Look at the recent technology mysql + innoDb internal storage engine of a book, chapter book - index and algorithm parameters mentioned meanings see table index information, especially for the record

  show index from table_name ## to view the index information for the table

  • table where the table name index
  •  Non_unique: non-unique indexes, you can see primary_key is 0, because must be unique
  • Key_name: Index name
  • Seq_in_index: the position of the index for that column, for the joint index more intuitive
  • Column_name: name index of the column
  • Collation: What is stored in the column, may be A or NULL, B + tree index is always A, i.e. sorted; Heap storage engine if it is used, and a hash index is established, this appears as NULL
  • Cardinality: critical value, the number of unique values ​​in the index identifies the estimated value, record Cardinality / table number should be as close to 1, if very small, and that users need to consider whether there is a need to create the index. When it is removed, and a small part of the data field from the table the high selectivity access attribute field is added to the B + tree index it is necessary
  • Sub_part: whether it is part of the column is indexed
  • Packed: keywords are compressed
  • Null: whether the index contains a NULL value
  • Index_type: type index, InnoDB storage engine only supports the B + tree index, so show BTREE
  • Comment: Comment

  Cardinality value is important, the optimizer will use to determine whether the index based on this value, but this value is not updated in real time, that is not a reference to the update will update the value, because the price is too high, is only an approximate value

  In the InnoDB storage engine, update Cardinality statistics takes place in two operations: insert and update. InnoDB storage engine to update Cardinality internal information strategy:

  •   The data in Table 1/16 has changed
  •   stat_modified_counter>2000 000 000

 

  The first strategy since the last time statistics Cardinality information, data sheet 1/16 has been changed, it is necessary to update the information Cardinality

  The second consideration is that, if a row in the data table is updated frequently operate, then the data in the table is not the actual increase, the change actually occurs or this line data, the first update policy can not apply this case, therefore, a counter inside start_modified_counter InnoDB storage engine,

  It is used to indicate the number of changes, when start_modified_counter 2 000 000 000, then the same update information Cardinality>

 

  

Guess you like

Origin www.cnblogs.com/manmanrenshenglu/p/12036620.html