Database info:
* MySQL 5.0
* InnoDB tablespace
* Over 500 GB of data
Background:
A common query in the application was running smoothly until recently the query began using the wrong index. Before it was using the right index but then as our dataset grew larger it changed the index it was using for some reason.
If I tell the query to USE INDEX (correct_index) then the query works fine. However, I'd like to have it set up so I don't have to use the USE INDEX syntax in the query.
Question:
What can I do to investigate why the query is using the wrong index? I've tried running ANALYZE TABLE [all tables involved] but nothing changed when running EXPLAIN on the query.
Is it worth it to try removing the index and then reapplying the index? This may not be a reasonable solution due to the length of time it would take to rebuild the index on my large dataset.
Is there some other way to get MySQL to use the correct index? Maybe by altering the index and then undoing the changes so MySQL re-reads the index.
Any help is appreciated...thanks in advance!
-- Brad
* MySQL 5.0
* InnoDB tablespace
* Over 500 GB of data
Background:
A common query in the application was running smoothly until recently the query began using the wrong index. Before it was using the right index but then as our dataset grew larger it changed the index it was using for some reason.
If I tell the query to USE INDEX (correct_index) then the query works fine. However, I'd like to have it set up so I don't have to use the USE INDEX syntax in the query.
Question:
What can I do to investigate why the query is using the wrong index? I've tried running ANALYZE TABLE [all tables involved] but nothing changed when running EXPLAIN on the query.
Is it worth it to try removing the index and then reapplying the index? This may not be a reasonable solution due to the length of time it would take to rebuild the index on my large dataset.
Is there some other way to get MySQL to use the correct index? Maybe by altering the index and then undoing the changes so MySQL re-reads the index.
Any help is appreciated...thanks in advance!
-- Brad
Comment