| От | Kevin Grittner |
|---|---|
| Тема | Re: Performance problems with prepared statements |
| Дата | |
| Msg-id | 470F7EC5.EE98.0025.0@wicourts.gov обсуждение |
| Ответ на | Re: Performance problems with prepared statements (Theo Kramer <theo@flame.co.za>) |
| Список | pgsql-performance |
>>> On Fri, Oct 12, 2007 at 9:57 AM, in message
<1192201021.6170.47.camel@localhost.localdomain>, Theo Kramer
<theo@flame.co.za> wrote:
>
> select * from foo where
> (a = a1 and b = b1 and c >= c1) or
> (a = a1 and b < b1) or
> (a > a1)
> order by a, b desc, c;
>
> I have, however, found that transforming the above into a union based
> query performs substantially better.
Another approach which often performs better is to rearrange the logic
so that the high-order predicate is AND instead of OR:
select * from foo where
( a >= a1
and ( a > a1
or ( b <= b1
and ( b < b1
or ( c >= c1 )))))
order by a, b desc, c;
With the right index and a limit on rows, this can do particularly well.
-Kevin
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера