Comment 7 for bug 606914

Revision history for this message
Stuart Bishop (stub) wrote : Re: [Bug 606914] Re: Bug.initial_message fetches all of the bug's messages

On Mon, Jul 19, 2010 at 9:42 PM, Graham Binns <email address hidden> wrote:
> On 19 July 2010 14:54, Jeroen T. Vermeulen <email address hidden> wrote:
>> On further inspection I'm pretty certain this is not the cause of the
>> timeouts, but it's definitely a bad thing.  All the more so if we're
>> often fetching it unnecessarily.  I'm working up a fix—the main question
>> is why initial_message sorts by id instead of by creation date and id.
>> May be a performance issue.
>
> I've already got a fix ready to land (see linked, then unlinked, then
> re-linked branch). Is there a particular reason to sort by creation
> date and id?

sorting by id is equivalent to sorting by datecreated, as creation
date should never change.

sorting by datecreated annoys tests, as all messages created in the
same transaction have the same datecreated and have an indeterminate
order. We also don't have an index on Message.datecreated, so this
would currently slow.

For the latest message, sorting by (datecreated DESC, id DESC) would
arguably be the most correct, but just sorting by id is faster,
requires no extra indexes to maintain, and meets our needs.

So please just sort by id unless you want to fix this bug twice :)

--
Stuart Bishop <email address hidden>
http://www.stuartbishop.net/