create table foo (id, name varchar(255));
create table foo_values (id, foo_id, name varchar(255), value varchar(255));
create table bar (id, name varchar(255));
create table bar_values (id, bar_id, name varchar(255), position integer);
我们查询会是什么样是否ORDER BY列必须是索引
select * from foo_values where foo_id=<foo_id> and name=<some-name> order by value;
select * from bar_values where bar_id=<bar_id> and name=<some-name> order by position;
We have a multi key index for foo_id and name in foo_values.
We have a multi key index for bar_id and name in bar_values.
是否有意义,包括在各自的关键指标值和位置或者是它不需要的部分。
如果您将第三列添加到多键索引,它会更慢。 –