結果一:與執行計畫相關的索引(出現在possible keys的那些),索引的數量與sql執行消耗時間成正比。
create index idx1 on test_index_performance (col1);
create index idx2 on test_index_performance (col1,col2);
create index idx3 on test_index_performance (col1,col2,col3);
create index idx4 on test_index_performance (col1,col2,col3,col4);
create index idx5 on test_index_performance (col1,col2,col3,col4,col5);
create index idx6 on test_index_performance (col1,col2,col3,col4,col5,col6);
create index idx7 on test_index_performance (col1,col2,col3,col4,col5,col6,col7);
create index idx8 on test_index_performance (col1,col2,col3,col4,col5,col6,col7,col8);
create index idx9 on test_index_performance (col1,col2,col3,col4,col5,col6,col7,col8,col9);
create index idx10 on test_index_performance (col1,col2,col3,col4,col5,col6,col7,col8,col9,col10);
執行以下語句
select count(*) from test_index_performance where col1=』a』 ;
– show profile for query 1; 結果的statistics部分
– 1索引0.000070
– 2索引0.000083
– 3索引0.000107
– 4索引0.000112
– 5索引0.000126
– 6索引0.000155
– 7索引0.000152
– 8索引0.000164
– 9索引0.000187
mysql冗餘索引 MySQL 冗餘和重複索引
冗餘和重複索引冗餘和重複索引的概念 mysql允許在相同列上建立多個索引,無論是有.冗餘和重複索引 冗餘和重複索引的概念 mysql允許在相同列上建立多個索引,無論是有意的還是無意的。mysql需要單獨維護重複的索引,香港虛擬主機,並且優化器在優化查詢的時候也需要逐個地進行考慮,香港虛擬主機,這會影...
mysql 冗餘和重複索引
mysql允許在相同列上建立多個索引,無論是有意還是無意,mysql需要單獨維護重複的索引,並且優化器在優化查詢的時候也需要逐個地進行考慮,這會影響效能。create table test id intnot null primary key,a intnot null b intnot null,...
MySQL查詢冗餘索引和未使用過的索引
mysql5.7及以上版本提供直接查詢冗餘索引 重複索引和未使用過索引的檢視,直接查詢即可。查詢冗餘索引 重複索引 select from sys.schema redundant indexes 查詢未使用過的索引 select from sys.schema unused indexes 如果想...