Re: [GENERAL] Optimize query for listing un-read messages

2014-05-03 Thread Andreas Joseph Krogh
På lørdag 03. mai 2014 kl. 23:21:21, skrev Alban Hertroys mailto:haram...@gmail.com>>: On 03 May 2014, at 12:45, Andreas Joseph Krogh wrote: > Do you really need to query message_property twice? I would think this would give the same results: > > SELECT >     m.id                         

Re: [GENERAL] Optimize query for listing un-read messages

2014-05-03 Thread Alban Hertroys
On 03 May 2014, at 12:45, Andreas Joseph Krogh wrote: > Do you really need to query message_property twice? I would think this would > give the same results: > > SELECT > m.id AS message_id, > prop.person_id, > coalesce(prop.is_read, FALSE) AS is_read, >

Re: [GENERAL] Optimize query for listing un-read messages

2014-05-03 Thread Andreas Joseph Krogh
På lørdag 03. mai 2014 kl. 11:51:08, skrev Alban Hertroys mailto:haram...@gmail.com>>: On 01 May 2014, at 13:06, Andreas Joseph Krogh wrote: > I have the following query to list all un-read messages for person with id=1: >  > SELECT >     m.id                          AS message_id, >     

Re: [GENERAL] Optimize query for listing un-read messages

2014-05-03 Thread Alban Hertroys
On 01 May 2014, at 13:06, Andreas Joseph Krogh wrote: > I have the following query to list all un-read messages for person with id=1: > > SELECT > m.id AS message_id, > prop.person_id, > coalesce(prop.is_read, FALSE) AS is_read, > m.subject > FROM messag

[GENERAL] Optimize query for listing un-read messages

2014-05-02 Thread Andreas Joseph Krogh
Hi all,   I have a schema where I have lots of messages and some users who might have read some of them. When a message is read by a user I create an entry i a table message_property holding the property (is_read) for that user.   The schema is as follows:   drop table if exists message_property;