I would like to suggest improving the indices on the follow_links table.
Currently, the indices on the table are:
'primary key' => array('lid'),
'unique keys' => array(
'uid_name' => array('uid', 'name'),
),
With the current indices, mysql has to do a filesort:
mysql> explain SELECT * FROM follow_links WHERE uid = 0 ORDER BY weight ASC;
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
| 1 | SIMPLE | follow_links | NULL | ref | uid_name | uid_name | 4 | const | 10 | 100.00 | Using index condition; Using filesort |
The select query on follow_links table can be optimized by adding a new index.
mysql> ALTER TABLE `follow_links` ADD INDEX `uid_weight` (`uid`, `weight`);
mysql> explain SELECT * FROM follow_links WHERE uid = 0 ORDER BY weight ASC;
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
| 1 | SIMPLE | follow_links | NULL | ref | uid_name,uid_weight | uid_weight | 4 | const | 10 | 100.00 | Using index condition |
Comments
Comment #2
karolinamHere is the patch which adds the
uid_weightindex.Comment #3
karolinamComment #4
karolinamComment #5
fengtan+1, patch looks good
Comment #6
astonvictor commentedD7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.