Does a multi-column index work for single column selects too?

后端 未结 3 2115
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 01:22

I\'ve got (for example) an index:

CREATE INDEX someIndex ON orders (customer, date);

Does this index only accelerate queries where cust

3条回答
  •  暖寄归人
    2020-12-29 01:56

    I'm pretty sure this will work, yes - it does in MS SQL Server anyway.

    However, this index doesn't help you if you need to select on just the date, e.g. a date range. In that case, you might need to create a second index on just the date to make those queries more efficient.

    Marc

提交回复
热议问题