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.

Comments

voxpelli’s picture

Status: Active » Needs review
quicksketch’s picture

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!

Status: Fixed » Closed (fixed)

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