Geo Carncross <[EMAIL PROTECTED]> writes:

> A better query would be:
>
> SELECT COUNT(*) FROM dbmail_messages WHERE mailbox_idnr='5' AND
> (status='0' OR status='1') UNION
> SELECT COUNT(*) FROM dbmail_messages WHERE mailbox_idnr='5' AND
> (status='0' OR status='1') AND seen_flag=1 UNION
> SELECT COUNT(*) FROM dbmail_messages WHERE mailbox_idnr='5' AND
> (status='0' OR status='1') AND recent_flag=1;

That made *no* sense.  What are you trying to achieve?

> Then having the following indexes:
>       mailbox_idnr
>       mailbox_idnr,status
>       mailbox_idnr,status,seen_flag
>       mailbox_idnr,status,recent_flag

The first two are not needed.  Their functions are included in either
of the last two.  That's why ordering the columns in composite indexes
is important.

> We should also include the following indexes:
>       mailbox_idnr,message_idnr,status
>       mailbox_idnr,message_idnr

Same with these -- the latter is not needed.

-tih
-- 
Don't ascribe to stupidity what can be adequately explained by ignorance.

Reply via email to