Reputation: 1541
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
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