Re: Different execution plans for semantically equivalent queries
В списке pgsql-performance по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Different execution plans for semantically equivalent queries |
| Дата | |
| Msg-id | 15642.1297027741@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Different execution plans for semantically equivalent queries (Mikkel Lauritsen <renard@tala.dk>) |
| Ответы |
Re: Different execution plans for semantically equivalent queries
|
| Список | pgsql-performance |
Mikkel Lauritsen <renard@tala.dk> writes:
> I would like to do a query which retrieves the newest record for each
> type, and the persistence framework that I'm using does something
> which is structurally like
> SELECT * FROM table t1 WHERE 0 = (SELECT COUNT(*) FROM table t2 WHERE
> t2.type = t1.type AND t2.timestamp > t1.timestamp)
I suspect that *any* database is going to have trouble optimizing that.
You'd be well advised to lobby the persistence framework's authors to
produce less brain-dead SQL. The NOT EXISTS formulation seems to
express what's wanted much less indirectly.
regards, tom lane
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера