Created
April 3, 2014 18:52
-
-
Save jklein/9960540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've been doing a bunch of auditing of the homepage (both signed in and signed out), and my latest discovery involves this unexpectedly expensive query: | |
select Taxonomy.taxonomy_id as Taxonomy__taxonomy_id, | |
Taxonomy.top_level_id as Taxonomy__top_level_id, | |
Taxonomy.name as Taxonomy__name, | |
Taxonomy.metadata as Taxonomy__metadata, | |
Taxonomy.shard_id as Taxonomy__shard_id, | |
Taxonomy.old_shard as Taxonomy__old_shard, | |
Taxonomy.migration_lock as Taxonomy__migration_lock, | |
Taxonomy.create_date as Taxonomy__create_date, | |
Taxonomy.update_date as Taxonomy__update_date | |
from taxonomies as Taxonomy | |
where Taxonomy.taxonomy_id = Taxonomy.top_level_id | |
This takes 20ms in prod, and runs twice on every page load it appears. Judging from the schema, we have both taxonomy_id and top_level_id indexed, but when I run an explain I get no index used. | |
Apparently the indexes don't apply with column equality checks. | |
I'll deal with the double query issue and make sure we only make it once, but |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment