Re: PostgreSQL OR performance - Mailing list pgsql-performance

From Jeff Davis
Subject Re: PostgreSQL OR performance
Date
Msg-id 1225902700.1432.53.camel@jdavis
Whole thread Raw
In response to PostgreSQL OR performance  ("Віталій Тимчишин" <tivv00@gmail.com>)
Responses Re: PostgreSQL OR performance
List pgsql-performance
On Wed, 2008-11-05 at 13:12 +0200, Віталій Тимчишин wrote:
> 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
>

What version are you using?

Have you run "VACUUM ANALYZE"?

Next, do:

EXPLAIN ANALYZE select something from table where condition1 or
condition2;

for each of the queries, unless that query takes so long you don't want
to wait for the result. In that case, omit the "ANALYZE" and just do
"EXPLAIN ...".

Then post those results to the list. These tell us what plans PostgreSQL
is choosing and what it estimates the costs to be. If it's the output of
EXPLAIN ANALYZE, it also runs the query and tells us what the costs
really are.

From that, we can see where the planner is going wrong, and what you
might do to change it.

Regards,
    Jeff Davis


pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL OR performance
Next
From: "Kevin Grittner"
Date:
Subject: Create and drop temp table in 8.3.4