PostgreSQL OR performance

Поиск
Список
Период
Сортировка
От Віталій Тимчишин
Тема PostgreSQL OR performance
Дата
Msg-id 331e40660811050312u552cab53ifa88e493e1c4f7ac@mail.gmail.com
обсуждение исходный текст
Ответы Re: PostgreSQL OR performance  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PostgreSQL OR performance  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-performance
Hello.

For a long time already I can see very poor OR performance in postgres.
If one have query like "select something from table where condition1 or condition2" it may take ages to execute while
"select something from table where condition1" and "select something from table where condition2" are executed very fast and
"select something from table where condition1 and not condition2 union all select something from table where condition2" gives required results fast

For example, in my current query for "condition1" optimizer gives 88252, for "condition1 and not condition2" it is 88258, for "condition2" it is 99814.
And for "condition1 or condition2" it is 961499627680. And it does perform this way.

All is more or less good when "select" part is easy and query can be easily rewritten. But for complex queries it looks ugly and if the query is autogenerated, moving autogeneration mechanism from creating simple clean "where" to unions is not an easy task.

So the question is: Do I miss something? Can this be optimized?

В списке pgsql-performance по дате отправления:

Предыдущее
От: "praveen"
Дата:
Сообщение: Re: [ADMIN] Installation Error of postgresql-8.1.5 with perl.
Следующее
От: Peter Schuller
Дата:
Сообщение: lru_multiplier and backend page write-outs