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

Re: Poor query plan across OR operator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Hills <Mark(dot)Hills(at)framestore(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Poor query plan across OR operator
Date: 2010-01-26 16:41:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Mark Hills <Mark(dot)Hills(at)framestore(dot)com> writes:
> One of our most-used queries performs poorly (taking over 2 seconds) and a 
> tiny amount of refactoring shows it can be fast (less than 1ms) by 
> transforming the OR case (which spans two tables) into a UNION.

I'd suggest going with the UNION.  We are unlikely to make the planner
look for such cases, because usually such a transformation would be a
net loss.  It seems like rather a corner case that it's a win even on
your example.

			regards, tom lane

In response to


pgsql-performance by date

Next:From: Richard NeillDate: 2010-01-26 17:10:26
Subject: Should the optimiser convert a CASE into a WHERE if it can?
Previous:From: Grzegorz JaśkiewiczDate: 2010-01-26 16:10:36
Subject: Re: Poor query plan across OR operator

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