Re: Case expression pushdown

From: Gilles Darold <gillesdarold(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Case expression pushdown
Date: 2021-07-07 18:28:34
Message-ID: 5067476a-1ee3-f77c-8f3b-6a39d8a3cc54@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 07/07/2021 à 18:55, Gilles Darold a écrit :
> Le 07/07/2021 à 18:50, Gilles Darold a écrit :
>>
>> Great, I changing the state in the commitfest to "Ready for committers".
>>
>>
> I'm attaching the v5 patch again as it doesn't appears in the Latest
> attachment list in the commitfest.
>
>
And the review summary:

This patch allows pushing CASE expressions to foreign servers, so that:

  - more types of updates could be executed directly
  - full foreign table scan can be avoid
  - more push down of aggregates function

The patch compile and regressions tests with assert enabled passed
successfully.
There is a compiler warning but it is not related to this patch:

        deparse.c: In function ‘foreign_expr_walker.isra.0’:
        deparse.c:891:28: warning: ‘collation’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
          891 |       outer_cxt->collation = collation;
              |       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
        deparse.c:874:10: warning: ‘state’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
          874 |  else if (state == outer_cxt->state)
              |          ^

The regression test for this feature contains the use cases where push
down of CASE clause are useful.
Nested CASE are also part of the regression tests.

The patch adds insignificant overhead by processing further than before
a case expression but overall it adds a major performance improvement
for queries on foreign tables that use a CASE WHEN clause in a predicate
or in an aggregate function.

This patch does what it claims to do without detect problem, as expected
the CASE clause is not pushed when a local table is involved in the CASE
expression of if a non default collation is used.

Ready for committers.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2021-07-07 18:42:43 Re: Numeric x^y for negative x
Previous Message Pavel Stehule 2021-07-07 18:19:34 Re: badly calculated width of emoji in psql