# HG changeset patch # User Daniele Nicolodi # Date 1320752814 -3600 # Node ID 8da56d2a70d6797ddf7183dced827326b869fe49 # Parent 5e2d298e01ef5a400aa1c1e4dbe9e07faf4e0a5a Enormously speed up activity view. diff -r 5e2d298e01ef -r 8da56d2a70d6 src/ltpdarepo/views/browse.py --- a/src/ltpdarepo/views/browse.py Tue Nov 08 12:22:38 2011 +0100 +++ b/src/ltpdarepo/views/browse.py Tue Nov 08 12:46:54 2011 +0100 @@ -679,8 +679,10 @@ # collect number of objects for each interval curs.execute("""SELECT ts.begin AS date, COUNT(objmeta.obj_id) AS count FROM timeintervals AS ts - LEFT OUTER JOIN `%s`.objmeta ON (objmeta.submitted BETWEEN ts.begin AND ts.end) - GROUP BY ts.begin, ts.end""" % database) + LEFT OUTER JOIN (SELECT obj_id, submitted FROM `%s`.objmeta + WHERE submitted > %%s AND submitted < %%s) AS objmeta + ON (objmeta.submitted BETWEEN ts.begin AND ts.end) + GROUP BY ts.begin, ts.end""" % database, (begin, end + dt)) activity = curs.fetchall()