With 170 feeds in the aggregator and trimming the archived items to only the past 7 days, I find the following query used in building the admin/aggregator page is timing out on the browser, and taking a minute or more through the mysql command line:
SELECT f.*, COUNT(i.iid) AS items FROM aggregator_feed f LEFT JOIN aggregator_item i ON f.fid = i.fid GROUP BY f.fid;
Curiously, tracing this down I discovered the aggregator_item table still contained items from two years go (no expiry) and double curiously, I found that trimming the list of items down from two years worth (about 50,000 entries) to just a week's worth (about 5000) only improved the computation time for that query by about 20%.
I'm not sure if there is a quick fix for this (other than to remove the count from the display) -- a long-term fix might be to compute the feed item counts as items are added to the feed and then store this total in aggregator_feed instead of computing it on the fly; that value may be useful in other display pages as well.
Comment | File | Size | Author |
---|---|---|---|
#6 | fid_idx.patch | 1.31 KB | chx |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedthe query looks fine to me. Do we have the proper indexes in place?
Comment #2
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedCREATE TABLE aggregator_item (
iid int(10) NOT NULL auto_increment,
fid int(10) NOT NULL default '0',
title varchar(255) NOT NULL default '',
link varchar(255) NOT NULL default '',
author varchar(255) NOT NULL default '',
description longtext NOT NULL,
timestamp int(11) default NULL,
PRIMARY KEY (iid)
) TYPE=MyISAM;
No index on fid. guess somebody who uses this module should add one.
Comment #3
dopry CreditAttribution: dopry commentedfid is still a candidate for getting indexed. I'll roll a patch after 4.7 rc hits.
Comment #4
Dries CreditAttribution: Dries commentedFeel free to roll a patch sooner than that. Looks like a critical performance improvement.
On drupal.org that query takes 4.8 seconds! :/
Note the change in the number of rows. After adding an index, the query takes 0.61 seconds (still slow-ish).
Comment #5
chx CreditAttribution: chx commentedGiven the luminaries that followed up here, I am surprised this is not yet tackled.
I will roll one for 4.7 if this is in. We have branch support, yay!
Comment #6
chx CreditAttribution: chx commentedDude, where's the patch??
Comment #7
Dries CreditAttribution: Dries commentedShouldn't that upgrade go in aggregator.install?
Comment #8
drummCommitted to HEAD.
Comment #9
drummDries- looks like we simultaneously reviewed.
I thought about this, but nothing else in core has broken out of system_update_N() yet. It would make a bunch of select menus on the upgrade selection page, but maybe thats a problem with that UI.
Comment #10
(not verified) CreditAttribution: commented