On 09/27/2012 03:55 PM, Scott Marlowe wrote:

Have you tried re-writing this query first?  Is there a reason to have
a bunch of subselects instead of joining the tables?  What pg version
are you running btw?  A newer version of pg might help too.

Wow, yeah. I was just about to say something about that. I even pasted it into a notepad and started cutting it apart, but I wasn't sure about enough of the column sources in all those subqueries.

It looks like it'd be a very, very good candidate for a window function or two, and maybe a few CASE statements. But I'm about 80% certain it's not very efficient as is.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-444-8534
stho...@optionshouse.com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to 
this email


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

Reply via email to