Subject | Re: [firebird-support] Re: Email system - read/unread messages database design ... |
---|---|
Author | Alexandre Benson Smith |
Post date | 2007-01-06T19:00:03Z |
westsorkin wrote:
not read messages. The second will perform better (of course, if an
index exists on IsRead and if this Index will filter out a lot of messages).
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
> Thanks for the comments!This query will not use an index (ib available) on UserMessages.IsRead
>
> Of course, I will put FK and I will have a UserID parameter in my
> query. So, now the question is, how slower is the first query (if it
> is), compared to the second one:
>
> select
> Message.id, Message.Subject
> from
> Messages
> inner join UserMessages on (UserMessages.MessageID = Messages.ID)
> where
> (
> (:show_only_unread = 'YES' and UserMessages.IsRead = 'NO') or
> (:show_only_unread = 'NO')
> )
> and
> (
> UserMessages.UserId = :UserID
> )
>
>This Query will use an index on UserMessage.IsRead i available.
> select
> Message.id, Message.Subject
> from
> Messages
> inner join UserMessages on (UserMessages.MessageID = Messages.ID)
> where
> UserMessages.UserId = :UserID and
> UserMessages.IsRead = 'NO'
>
> When parameter "show_only_unread" is "No", there should not be anyThe former query will have the same performance for all messages or for
> performance differences, right? But what about when "show_only_unread"
> is "Yes"?
>
not read messages. The second will perform better (of course, if an
index exists on IsRead and if this Index will filter out a lot of messages).
> WestSorkin--
>
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br