Skip site navigation (1) Skip section navigation (2)

Re: PostgreSQL OR performance

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Віталій Тимчишин <tivv00(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL OR performance
Date: 2008-11-05 16:31:40
Message-ID: 1225902700.1432.53.camel@jdavis (view raw or flat)
Thread:
Lists: 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


In response to

Responses

pgsql-performance by date

Next:From: Kevin GrittnerDate: 2008-11-05 18:45:46
Subject: Create and drop temp table in 8.3.4
Previous:From: Tom LaneDate: 2008-11-05 15:34:51
Subject: Re: PostgreSQL OR performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group