Re: Getting query plan alternatives from query planner?

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Craig James <cjames(at)emolecules(dot)com>, Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, Shaun Thomas <sthomas(at)optionshouse(dot)com>
Cc: Stefan Keller <sfkeller(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Getting query plan alternatives from query planner?
Date: 2014-04-14 14:39:17
Message-ID: 1397486357.89780.YahooMailBasic@web122305.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Shaun Thomas <sthomas(at)optionshouse(dot)com> wrote:

> these issues tend to get solved through optimization fences.
> Reorganize a query into a CTE, or use the (gross) OFFSET 0 trick.
> How are these nothing other than unofficial hints?

Yeah, the cognitive dissonance levels get pretty high around this
issue. Some of the same people who argue strenuously against
adding hints about what plan should be chosen also argue against
having clearly equivalent queries optimize to the same plan because
they find the fact that they don't useful for coercing a decent
plan sometimes. That amounts to a hint, but obscure and
undocumented. (The OP may be wondering what this "OFFSET 0 trick"
is, and how he can use it.)

> Well... they're worse, really. Hints can be deprecated, disabled
> in configs, or ignored in extreme cases. Optimization fences are
> truly forever.

+1

With explicit, documented hints, one could search for hints of a
particular type should the optimizer improve to the point where
they are no longer needed. It is harder to do that with subtle
differences in syntax choice. Figuring out which CTEs or LIMITs
were chosen because they caused optimization barriers rather than
for their semantic merit takes some effort.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Eric Schwarzenbach 2014-04-14 14:59:52 Re: Getting query plan alternatives from query planner?
Previous Message Ryan Johnson 2014-04-14 14:22:42 Re: SSI slows down over time