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.
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.