Comment 12 for bug 607935

Robert Collins (lifeless) wrote :

so the 5 second query is 20s cold on qastaging, 300ms hot; this may be a cold cache effect.

However, what we want is the first and last 40 comments;

this seems reasonable and is 30ms rather than 300ms hot:

SELECT MessageChunk.blob, MessageChunk.content,
                          MessageChunk.id,
                          MessageChunk.message,
                          MessageChunk.sequence,
                          Message.datecreated,
                          Message.id,
                          Message.OWNER, Message.parent,
                                         Message.raw,
                                         Message.rfc822msgid,
                                         Message.subject
FROM BugMessage,
     Message,
     MessageChunk
WHERE Message.id = MessageChunk.message
  AND BugMessage.message = Message.id
  AND BugMessage.bug = 1
  and (bugmessage.index < 41 or bugmessage.index > (select max(index) -40 from bugmessage where bug=1))
 ORDER BY BugMessage.index, Message.datecreated,
         Message.id,
         MessageChunk.sequence;