1

主键中的列顺序是否会根据 select 语句中给出的列顺序影响相关查询的性能?

例子:

primary key (col1, col2, col3);

select col2, col3 from table;

-> 这个选择会使用 pk 索引吗?

select col3,col1,col2 from table;

-> 这个选择会使用 pk 索引吗?

4

1 回答 1

2

不,订单不相关。但是,只有在where子句中使用所有主键列(如所有索引)时,才使用主键索引。

select ... from table where col1 = ... and col2 = ... and col3 = ...;

于 2018-07-16T19:17:55.097 回答