Re: How can i monitor exactly what (partition) tables are accessed by a query?

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: How can i monitor exactly what (partition) tables are accessed by a query?
Дата
Msg-id CAKFQuwaZxKfYog7cOnS_EYq73kTfd2w7GPAkY7CzWoEF-qRJtw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Re: How can i monitor exactly what (partition) tables are accessed by a query?  (Alban Hertroys <haramrae@gmail.com>)
Ответы Re: How can i monitor exactly what (partition) tables are accessed by a query?  (Alban Hertroys <haramrae@gmail.com>)
Список pgsql-general
On Friday, September 19, 2014, Alban Hertroys <haramrae@gmail.com> wrote:
On 19 Sep 2014, at 3:50, Robert Nix <robert@urban4m.com> wrote:

> Thanks, David.
>
> I have read that page many times but clearly I have forgotten this:
>
>       • Constraint exclusion only works when the query's WHERE clause contains constants (or externally supplied parameters). For example, a comparison against a non-immutable function such asCURRENT_TIMESTAMP cannot be optimized, since the planner cannot know which partition the function value might fall into at run time.
>
> I had worked around this "issue" some time ago but I clearly should have documented _why_ I worked around it in the way I did.

What may be worth a try is to join against a UNION ALL of your partitions, with each section of the UNION having an explicirt WHERE clause matching your partitioning constraints.
The idea there is that such a UNION could provide the explicit constant WHERE clauses that your JOIN implicitly depends on.

That makes no sense.  If you join against partitions instead of the parent then the contents of the where clause on those partition queries is irrelevant.  Furthermore, combining a bunch of of queries via union is exactly what PostgreSQL is doing when it executes the original plan - it's just you are doing it manually.

I may be getting your thoughts confused here but if so that's mostly due to the lack of any concrete query examples to evaluate.

David J.

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: cloning database
Следующее
От: Szymon Guz
Дата:
Сообщение: Re: Why isn't Java support part of Postgresql core?