Active
Project:
DB Tuner
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2011 at 09:42 UTC
Updated:
14 Mar 2011 at 17:36 UTC
Using the excellent New Relic, I've noticed thousands of queries in the format SELECT t.tid, t . * FROM term_data t WHERE t.name = 'SOMEWORDHERE' so I wanted to look if it's optimized.
I noticed there was no index on the 'name' column. Not sure whether it is needed. However, I ran it through EXPLAIN without the index and with it, and MySQL clearly uses the index when it is available!
See the attached screenshots. If you think this is a valid find, maybe it is worth adding it to DB Tuner.
| Comment | File | Size | Author |
|---|---|---|---|
| term_data_with_name_index.JPG | 22.18 KB | vacilando | |
| term_data_without_name_index.JPG | 22.41 KB | vacilando |
Comments
Comment #1
mikeytown2 commentedThis index is actually already in the code but it appears that the dbtuner_empty_index function is messing up in this case.
Comment #2
mikeytown2 commentedLooking over the code and name is already apart of a multi-index
So this might take some time...
Comment #3
vacilando commentedIndeed, it's a part of indices vid_name and taxonomy_tree. However, these are not used by MySQL for the very frequent query cited above.
Could you explain what you mean by "this might take some time"? Is it because you focus on columns with no indices at all first and leave cases like this for later? If so, why?
Comment #4
mikeytown2 commentedLook at line 680
http://drupalcode.org/project/dbtuner.git/blob/refs/heads/6.x-1.x:/dbtun...
I already have the name index on the table term_data in the code. I need to rework this module to take into account more complex data structures.