Sorry for the delayed response. I've been away for a few days. I'm using PostgreSQL 8.0.8. It is using the indexes because it automatically typecasts the char to an int. However, an IN or OR clause causes it to scan the index twice and then merge the results. This is significantly slower than a single index scan.
I've been testing the query I sent last week and performance on SquirrelMail appears to be faster as well as some IMAP filtering Perl scripts that I wrote. Unfortunately if the flags do not remain in their current order there is no guarantee that we can get away with the less than operator instead of IN/OR. I'll keep digging and see if I can find a more efficient way. Thanks, Tim Mattison
