Re: Optimize query for listing un-read messages
От | Brice André |
---|---|
Тема | Re: Optimize query for listing un-read messages |
Дата | |
Msg-id | CAOBG12ksaHi990-X3XOKzU6E3ne9kFP9L89n2Dg2+8A9yjxy4g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Optimize query for listing un-read messages (Andreas Joseph Krogh <andreas@visena.com>) |
Ответы |
Re: Optimize query for listing un-read messages
|
Список | pgsql-sql |
Forget my last answer : it was a stupid one... I tried to answer quickly, but with tiredness, it does not give good results.
For me, your problem of performance comes from the "WHERE NOT EXISTS (query)" because your query is executed on each result of the outer join.2014-05-04 18:53 GMT+02:00 Andreas Joseph Krogh <andreas@visena.com>:
På søndag 04. mai 2014 kl. 18:49:43, skrev Brice André <brice@famille-andre.be>:and it should be OK.Yes, I was a bit too fast. but replace it withWHERE NOT prop.is_read = TRUE
No, that also will be treated as an INNER JOIN, because it kills tuples where prop is null. I need entries where prop IS NULL (hence the LEFT OUTER JOIN) because messages without an entry in message_property must be treated as unread, the same as messages with an entry in message_property where is_read=FALSE.
Вложения
В списке pgsql-sql по дате отправления: