Closed (fixed)
Project:
Flag
Version:
6.x-2.0-beta1
Component:
Flag core
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Jun 2009 at 08:58 UTC
Updated:
4 Jan 2010 at 01:28 UTC
Jump to comment: Most recent file
I run an EXPLAIN on query that did a sort on the 'count' table in 'flag_count', which should be relatively common thing to do, e.g in Views. It gave a "using filesort". I fixed this by adding an index to the 'count' column.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | flag_indexes.patch | 1.7 KB | quicksketch |
| #2 | flag_improved_index_flag_counts_issue_489610.patch | 836 bytes | voxpelli |
Comments
Comment #1
quicksketchSeems like a good idea to me.
Comment #2
voxpelli commentedHere's a patch
Comment #3
quicksketchI combined this with #612602: Add index supporting the relationship in Views, as they both had the same update number. I put specifically in the 2.x branch since Drupal doesn't have any way of detecting if an index already exists and I didn't want to have conflicting updates between the 1.x branch and the 2.x branch. I'll try to hurry up the 2.x version for production use, as this seems like a pretty big improvement in our queries.
Comment #5
premanup commentedI build a block of popular users on my site using modules Views and Flag and discover it is a the longest SQL request in my life. It takes about 3 min.
There is SQL:
I tried modify indexes for table flag_counts:
After this the same SQL became much faster - 0.28 sec!
So I think the field 'content_type' is superfluous in primary key of table 'flag_counts', is not?
Comment #6
voxpelli commented@premanup: Open a new issue for that or at least set the status of this one to active again - otherwise this issue will look like fixed to everyone else.
Also - have you tested version 2 of Flag and seen if it has been fixed there?
Comment #7
premanup commented@voxpelli: Oh, thank you for advice, I've just set the status to active.
I didn't test version 2 but as far as I can see the function flag_schema using exactly the same definition of primary key for table 'flag_types' (line 300):
So I guess It should be changed to
Comment #8
quicksketchpremanup, you're recommending a different key change than this issue originally was created for. Please open a different issue explaining the situation.
Comment #9
premanup commented@quicksketch, ok, I've opened it here http://drupal.org/node/660316