current position:Home>How to write SQL to effectively use composite index?

How to write SQL to effectively use composite index?

2022-02-04 16:37:20 Alibaba cloud Q & A

How to write sql Can effectively use the composite index ?




Take the answer 1:

Composite index , It's also called composite index , Users can index multiple columns , This index is called a composite index .

When we create a composite index , Such as (k1,k2,k3), It's equivalent to creating (k1)、(k1,k2) and (k1,k2,k3) Three indexes , This is the left most matching principle .

select * from table where k1=A AND k2=B AND k3=D

About Composite Index , We need to focus on queries Sql The order of conditions , Ensure that the leftmost matching principle is effective , At the same time, unnecessary redundant indexes can be deleted .


copyright notice
author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041637191461.html

Random recommended