Mysql covering vs composite vs column index

后端 未结 4 692
走了就别回头了
走了就别回头了 2020-11-30 00:51

In the following query

SELECT  col1,col2
FROM    table1
WHERE   col3=\'value1\'
  AND   col4=\'value2\'

If I have 2 separate indexes one on

4条回答
  •  -上瘾入骨i
    2020-11-30 01:07

    Compound index is not the same as a composite index.

    • Composite index covers all the columns in your filter, join and select criteria. All of these columns are stored on all of the index pages accordingly throughout the index B-tree.
    • Compound index covers all the filter and join key columns in the B-tree, but keeps the select columns only on the leaf pages as they will not be searched, rather only extracted! This saves space and consequently creates less index pages, hence faster I/O.

提交回复
热议问题