Re: Partitioning and postgres_fdw optimisations for multi-tenancy - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: Partitioning and postgres_fdw optimisations for multi-tenancy
Date
Msg-id CAExHW5vAzbcwT7bvWKTsrZti_Sp1iMXDZhbRDb-oD91LSqkURg@mail.gmail.com
Whole thread Raw
In response to Re: Partitioning and postgres_fdw optimisations for multi-tenancy  (Etsuro Fujita <etsuro.fujita@gmail.com>)
Responses Re: Partitioning and postgres_fdw optimisations for multi-tenancy
List pgsql-hackers
On Fri, Jul 17, 2020 at 8:24 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
>
> On Fri, Jul 17, 2020 at 1:56 AM Alexey Kondratov
> <a.kondratov@postgrespro.ru> wrote:
> > However, there is an issue with aggregates as well. For a query like:
> >
> > SELECT
> >      count(*)
> > FROM
> >      documents
> > WHERE
> >      company_id = 5;
> >
> > It would be great to teach planner to understand, that it's a
> > partition-wise aggregate as well, even without GROUP BY company_id,
> > which doesn't always help as well. I'll try to look closer on this
> > problem, but if you have any thoughts about it, then I'd be glad to
> > know.
>
> The reason why the aggregation count(*) isn't pushed down to the
> remote side is: 1) we allow the FDW to push the aggregation down only
> when the input relation to the aggregation is a foreign (base or join)
> relation (see create_grouping_paths()), but 2) for your case the input
> relation would be an append relation that contains the foreign
> partition as only one child relation, NOT just the foreign partition.
> The resulting Append path would be removed in the postprocessing (see
> [1]), but that would be too late for the FDW to do the push-down work.
> I have no idea what to do about this issue.

Won't partitionwise aggregate push aggregate down to partition and
then from there to the foreign server through FDW? Something else must
be stopping it. May be whole-var expression?

-- 
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: expose parallel leader in CSV and log_line_prefix
Next
From: "David G. Johnston"
Date:
Subject: Error during make, second install