jacekn
jacekn

Reputation: 1541

Do we need multiple indexes on a given column in MySQL?

MySQL (Maria)

I've created an index on two columns.

entpcd -- Entity Type Code
enid -- Entity ID

Will MySQL use this index automatically for this query?

SELECT * FROM table_name WHERE entpcd='PN'

.. or do I need to define a separte single-field index for entpcd so that SELECT performs well?

Upvotes: 0

Views: 24

Answers (1)

Will Hartung
Will Hartung

Reputation: 118794

If MySQL decides to use an index for that query, then the index you created would qualify as one it could use.

I'm being horribly vague because the optimizer will do what the optimizer does. But, if you have enough rows in the table, and that's the only index available, it will be able to use that index.

Upvotes: 1

Related Questions