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

Re: two seperate queries run faster than queries ORed together

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org
Subject: Re: two seperate queries run faster than queries ORed together
Date: 2004-03-22 19:00:30
Message-ID: 405F37CE.9070302@selectacast.net (view raw or flat)
Thread:
Lists: pgsql-performance
Tom Lane wrote:
> Joseph Shraibman <jks(at)selectacast(dot)net> writes:
> 
>>No, pkey is not the primary key in this case. The number of entries in u 
>>that have pkey 260 and not boolfield is 344706.
> 
> 
> ... and every one of those rows *must* be included in the join input,

*If* you use one big join in the first place.  If postgres ran the query 
to first get the values with status == 3 from u, then ran the query to 
get the entries from d, then combined them, the result would be the same 
but the output faster.  Instead it is doing seq scans on both tables and 
doing an expensive join that returns only a few rows.


In response to

Responses

pgsql-performance by date

Next:From: Stephan SzaboDate: 2004-03-22 19:32:30
Subject: Re: two seperate queries run faster than queries ORed
Previous:From: Tom LaneDate: 2004-03-22 18:24:19
Subject: Re: two seperate queries run faster than queries ORed together

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