Possible speedup: Add an index for aggregator_item

msameer - November 22, 2006 - 11:40
Project:Drupal
Version:6.x-dev
Component:aggregator.module
Category:bug report
Priority:normal
Assigned:bdragon
Status:duplicate
Description

Before adding an index on fid:

desc SELECT i.title, i.timestamp, i.link FROM aggregator_item i WHERE i.fid =5 ORDER BY i.timestamp DESC LIMIT 0, 20;

+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+
| 1 | SIMPLE | i | ALL | NULL | NULL | NULL | NULL | 2069 | Using where; Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------+

After adding an index on fid:
alter table aggregator_item add index(fid);

desc SELECT i.title, i.timestamp, i.link FROM aggregator_item i WHERE i.fid =5 ORDER BY i.timestamp DESC LIMIT 0, 20;
+----+-------------+-------+------+---------------+------+---------+-------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+-------+------+-----------------------------+
| 1 | SIMPLE | i | ref | fid | fid | 4 | const | 93 | Using where; Using filesort |
+----+-------------+-------+------+---------------+------+---------+-------+------+-----------------------------+

#1

FiReaNG3L - December 12, 2006 - 03:30
Title:Index for aggregator_item» Possible speedup: Add an index for aggregator_item

Adding an index to (fid,timestamp) get rid of the 'using filesort' clause. This should yield a performance improvement with big feeds - didn't have any to benchmark with.

Drupal 5.0 could benefit from this, as it have only an index on 'fid'.

#2

bdragon - December 12, 2006 - 06:31
Version:4.7.4» 5.x-dev
Assigned to:Anonymous» bdragon
Status:active» patch (code needs review)

Here's a patch for DRUPAL-5.

As an aside, this problem has been partially fixed in HEAD and forgotton in DRUPAL-4-7.
Here's the original issue.
http://drupal.org/node/14400

Adding timestamp to the key reduces the need to filesort, I agree.
And this time, let's remember to backport the fix, heh.

AttachmentSize
aggregrator-better-key.patch926 bytes

#3

FiReaNG3L - December 12, 2006 - 17:23

Looks great. All we need now is benchmarks on significantly large feeds, with concurrency if possible.

#4

drumm - December 31, 2006 - 06:19
Version:5.x-dev» 6.x-dev

#5

Zen - April 30, 2007 - 06:54
Status:patch (code needs review)» patch (code needs work)

Patch applies, but:
- There is no update path.
- I believe that it should be investigated if an additional index (fid, timestamp) should be added or the existing one modified..
- code style issue with the commas in the index.

-K

#6

msameer - April 30, 2007 - 09:17

I can't do anything for the patch anymore. I'm not using core agggregator anymore. It also seems that the patch has a low priority.

#7

catch - November 6, 2007 - 10:58
Status:patch (code needs work)» duplicate

Duplicate of: http://drupal.org/node/164532

 
 

Drupal is a registered trademark of Dries Buytaert.