Code review comment for lp:~jtv/launchpad/bug-798297

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The query that looks for the last Message.id to be omitted doesn't play well with indexes. Shouldn't usually be a problem, but can cause annoying slowdowns.

We can fix it by indexing Message.datecreated, and changing the query to:

SELECT max(id)
FROM Message
WHERE datecreated = (
    SELECT max(datecreated)
    FROM Message
    WHERE datecreated < %(since)s)

On a hot cache, this will scan back through years in a few milliseconds.

« Back to merge proposal