Re: Get the planner used by a query?

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Get the planner used by a query?
Дата
Msg-id CAKJS1f8zmVedgD+uXTCm-urZASNStkb4uHq0eYD86EfKHka_qA@mail.gmail.com
обсуждение исходный текст
Ответ на Get the planner used by a query?  (Behrang Saeedzadeh <behrangsa@gmail.com>)
Список pgsql-performance
On Wed, 9 Oct 2019 at 19:21, Behrang Saeedzadeh <behrangsa@gmail.com> wrote:
>
> Is there a way to display the planner algorithm used by a query, either in EXPLAIN or in a different way?

There's not really any simple way to know. If the number of relations
in the join search meets or exceeds geqo_threshold then it'll use the
genetic query optimizer. However, knowing exactly how many relations
are in the join search is not often simple since certain types of
subqueries can be pulled up into the main query and that can increase
the number of relations in the search.

If you don't mind writing C code, then you could write an extension
that hooks into join_search_hook and somehow outputs this information
to you before going on to call the geqo if the "enable_geqo &&
levels_needed >= geqo_threshold" condition is met.  Besides that, I
don't really know if there's any way.  You could try editing the
geqo_seed and seeing if the plan changes, but if it does not, then
that does not mean the geqo was not used, so doing it that way could
be quite error-prone.  You'd only be able to tell the geqo was being
used if you could confirm that changing geqo_seed did change the plan.
(And you could be certain the plan did not change for some other
reason like an auto-analyze).



--
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services



В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Query slows when used with view
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Modification of data in base folder and very large tables