On 12/12/11 7:46 PM, Paul J Stevens wrote:
On 12/12/2011 03:15 AM, Yaroslav Tykhiy wrote:

CREATE INDEX dbmail_messages_mbox_msg ON dbmail_messages
(mailbox_idnr,message_idnr);

Sounds great. Surprising given the existing indexes, but great.

I wouldn't say it's too surprising. With the stock indexes, the DB can efficiently locate all messages in a given mailbox, but then it has to scan those records sequentially to find out MAX(message_idnr), which can be slow in a large mailbox. And with this custom index it can just fetch the MAX value from the index because it's btree by default in Pg.

Wonder if this would also benefit mysql users...

IMHO it's likely to provided that the mysql indexes used are ordered. E.g., a btree will do but a hash won't -- sorry, I have no idea what actual mysql index types are so I'm just speculating here.

Yar
_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to