Re: [PERFORM] RE: [PERFORM] Re: [PERFORM] Sub-optimal plan for a paginated query on a view with another view inside of it.

From: <slapo(at)centrum(dot)sk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Igor Neyman <ineyman(at)perceptron(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [PERFORM] RE: [PERFORM] Re: [PERFORM] Sub-optimal plan for a paginated query on a view with another view inside of it.
Date: 2013-08-08 06:59:42
Message-ID: 20130808085942.3D228938@centrum.sk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I was afraid of something worse but hoping for something better in terms of maintainability. At least now I have a good explanation. :-)
I just hope the embedded view use won't interfere too much.
 
Thanks everyone.
 
Regards,
 
Peter Slapansky
 
______________________________________________________________
> Od: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> Komu: <slapo(at)centrum(dot)sk>
> Dátum: 07.08.2013 17:53
> Predmet: Re: [PERFORM] RE: [PERFORM] Re: [PERFORM] Sub-optimal plan for a paginated query on a view with another view inside of it.
>
> CC: "Igor Neyman", "Pavel Stehule", "pgsql-performance(at)postgresql(dot)org"
<slapo(at)centrum(dot)sk> writes:
> "Total runtime: 9.313 ms" in pgAdmin
> "Total runtime: 9.363 ms" in psql.
> But timing after the query finished was 912.842 ms in psql.

Well, that's the downside of increasing join_collapse_limit and
from_collapse_limit: you might get a better plan, but it takes a lot
longer to get it because the planner is considering many more options.

If you're sufficiently desperate, you could consider rewriting the query
so that its JOIN structure matches the join order that the planner chooses
at the high collapse_limit settings.  Then you can reduce the limits back
down and it'll still find the same plan.  This tends to suck from a query
readability/maintainability standpoint though :-(.

The prepared-query approach might offer a solution too, if the good plan
isn't dependent on specific parameter values.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Robert DiFalco 2013-08-08 18:06:41 Efficient Correlated Update
Previous Message Claudio Freire 2013-08-07 19:13:48 Re: Efficiently query for the most recent record for a given user