B
B
balberbro2020-04-14 07:59:15
MySQL
balberbro, 2020-04-14 07:59:15

Do I need an index on a part of a composite key in MySQL?

There is a composite PC key that consists of 4 values

​​user_id
customer_id
deal_id
invoice_id

If I need to search for three fields user_id, customer_id, deal_id, do I need to hang a separate index on them, or due to the fact that they are included in the composite key - search and so will it go fast?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-04-14
@Rsa97

Not necessary. These three fields are at the beginning of the index and the index can be used when searching through them.
Whether it will actually be used depends on whether (MySQL predicts) the lookup will be accelerated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question