Search Postgresql Archives

Re: Suboptimal query plan fixed by replacing OR with UNION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 5, 2012, at 3:51 PM, Tom Lane wrote:

> Steven Schlansker <steven@xxxxxxxxxxxx> writes:
>> Why is using an OR so awful here?
> 
> Because the OR stops it from being a join (it possibly needs to return
> some rows that are not in the semijoin of the two tables).
> 
>> Why does it pick a sequential scan?  Is this an optimizer bug
> 
> No.  It can't transform OR into a UNION because the results might not
> be the same.  I assume you don't care about removal of duplicates, or
> have some reason to know that there won't be any ... but the planner
> doesn't know that.
> 

Thanks for the insight here.  It still seems unfortunate that it picks a
sequential scan -- but if there really is no more efficient way to do this,
I will just rewrite the query.

Steven


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux