Re: Case expression pushdown - Mailing list pgsql-hackers

From Gilles Darold
Subject Re: Case expression pushdown
Date
Msg-id 5067476a-1ee3-f77c-8f3b-6a39d8a3cc54@gmail.com
Whole thread Raw
In response to Re: Case expression pushdown  (Gilles Darold <gilles@migops.com>)
List 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.




pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: badly calculated width of emoji in psql
Next
From: Dean Rasheed
Date:
Subject: Re: Numeric x^y for negative x