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

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Robert Nix <robert(at)urban4m(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How can i monitor exactly what (partition) tables are accessed by a query?
Date: 2014-09-19 08:18:53
Message-ID: CAF-3MvMgcqeCjC2attTgWA2bjK0VZm9iZBZwNzFN2gabEtFDRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19 September 2014 09:13, David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>> 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.

Perhaps. That depends on whether the planner will use the information
that the CHECK constraints in those partition tables provide; it
probably does, though.
Admittedly, a combination of E_NOCOFFEE and E_NOTENOUGHTIME caused me
to mix up the master table (for which that makes a lot more sense) and
the underlying partition tables there.

> 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.

Ah yes, it does. It's really the distribution of those same values in
the other side of the join that's causing the planning issues.

I suppose you could attempt to manually "partition" the left-hand side
of the join. That sounds like a recipe to end up with a really
inefficient query though - can the planner do that and did it discard
the option because it would cost more?

I'm just throwing around some ideas, whether they actually work for
you remains to be seen.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message cowwoc 2014-09-19 08:19:03 Re: Why isn't Java support part of Postgresql core?
Previous Message Dev Kumkar 2014-09-19 07:53:42 Re: [GENERAL] pg_multixact issues