On Wed, 2005-09-28 at 19:12 +0200, Paul J Stevens wrote:
> [EMAIL PROTECTED] wrote:
> > Reported By:                ekristen
> > adding the user_idnr to the dbmail_messages table would improve selecting
> > messages from the database for someone who would be writing a webmail
> > interface for dbmail. So upon message injection into the database just add
> > the user_idnr to the dbmail_messages as well, because you already have the
> > mailbox_idnr and the physmessage_id in there if you just add the user_idnr
> > it would make querying the database 100% easier.
> 
> There is such a thing as JOIN in sql that will do in sql what you want to do 
> in
> the schema:
> 
> to get all messages for a user
> 
> select * from dbmail_messages
>  left join dbmail_mailboxes ON
>    dbmail_messages.mailbox_idnr=dbmail_mailboxes.mailbox_idnr
>  left join dbmail_users ON
>    dbmail_mailboxes.owner_idnr = dbmail_users.user_idnr
> where dbmail_users.userid="<someuserid>";

And faster!

dbmail_mailboxes/users have fewer rows, so the indexes for user_idnr
will be smaller (and have less duplicates) and thus take less time to
search.

-- 
Internet Connection High Quality Web Hosting
http://www.internetconnection.net/

Reply via email to