Subject | Re: Email system - read/unread messages database design ... |
---|---|
Author | westsorkin |
Post date | 2007-01-06T00:25:37Z |
Thanks for the comments!
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
)
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 any
performance differences, right? But what about when "show_only_unread"
is "Yes"?
WestSorkin
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
)
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 any
performance differences, right? But what about when "show_only_unread"
is "Yes"?
WestSorkin