I have a mysql table with approximatively 1.5 million lines.
This table contains a column called companies (integer) which contains few different values (3 or 4) and another column called orders (varchar) which contain a lot of different values (but some identical).
I created an multi-column index (type INDEX) with columns companies and orders.
I have a simple query
SELECT * FROM TABLE1 WHERE companies = 1 AND orders = '344A7884'
There is no execution time difference (around 4 secondes) when I execute this query with the index implemented or without.
The only way I found to get an execution time of around 1 seconde is to create an index only on "orders" and run the following transformed query:
SELECT * FROM (SELECT * FROM TABLE1 WHERE orders = 34467884) RQ1 WHERE companies = 1
That seems not to be very proper. Can someone explain me this strange behavior and suggest a better way to optimize the index?
Explainstatement results would be helpfulSHOW CREATE TABLE table1. It would be critical to post the output ofEXPLAIN SELECT * FROM .....