Download & Extend

Add index supporting the relationship in Views

Project:Flag
Version:6.x-2.x-dev
Component:Flag core
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Currently when adding a relationship to Views it's added as a join to flag_content with the fid and content_id columns and sometimes also the uid column.

Currently the only index that join can use is the unique index "fid_content_type_content_id_uid" consisting of: fid, content_type, content_id and uid

By analyzing my query I came to the conclusion that a far more optimal index for these joins would be a unique index like "fid_content_type_content_id_uid" - but without the content_type. By adding that to my MyISAM table I improved the performance of the query to be 25 times faster.

I'm attaching a patch that changes the current unique index by removing content_type from it - I don't think it will have any negative affect on any queries since there are still two indexes with content_type in it that can be used by them.

AttachmentSize
flag_improved_unique_index_flag_content.patch1.06 KB

Comments

#1

Status:active» needs review

#2

Version:6.x-1.1» 6.x-2.x-dev
Status:needs review» fixed

I bundled this in with #489610: Add index to 'count' in flag_count table, since they both used the same update number. Please see that issue for details. Thanks for the patch!

#3

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.