Re: Hints (was Poor performance using CTE) - Mailing list pgsql-performance

From Heikki Linnakangas
Subject Re: Hints (was Poor performance using CTE)
Date
Msg-id 50ACFBBD.30204@vmware.com
Whole thread Raw
In response to Re: Hints (was Poor performance using CTE)  ("Kevin Grittner" <kgrittn@mail.com>)
Responses Re: Hints (was Poor performance using CTE)
Re: Hints - experiences from other rdbms
Re: Hints (was Poor performance using CTE)
List pgsql-performance
On 21.11.2012 15:42, Kevin Grittner wrote:
> Better, IMV, would be to identify what sorts of hints people actually
> find useful, and use that as the basis for TODO items for optimizer
> improvement as well as inventing clear ways to specify the desired
> coercion. I liked the suggestion that a CTE which didn't need to be
> materialized because of side-effects or multiple references have a
> keyword. Personally, I think that AS MATERIALIZED x (SELECT ...)
> would be preferable to AS x (SELECT ... OFFSET 0) as the syntax to
> specify that.

Rather than telling the planner what to do or not to do, I'd much rather
have hints that give the planner more information about the tables and
quals involved in the query. A typical source of bad plans is when the
planner gets its cost estimates wrong. So rather than telling the
planner to use a nested loop join for "a INNER JOIN b ON a.id = b.id",
the user could tell the planner that there are only 10 rows that match
the "a.id = b.id" qual. That gives the planner the information it needs
to choose the right plan on its own. That kind of hints would be much
less implementation specific and much more likely to still be useful, or
at least not outright counter-productive, in a future version with a
smarter planner.

You could also attach that kind of hints to tables and columns, which
would be more portable and nicer than decorating all queries.

- Heikki


pgsql-performance by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Poor performance using CTE
Next
From: Claudio Freire
Date:
Subject: Re: Poor performance using CTE