Re: Optimize common expressions in projection evaluation

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Peifeng Qiu <pgsql(at)qiupf(dot)dev>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Optimize common expressions in projection evaluation
Date: 2022-12-05 04:08:20
Message-ID: CAKFQuwYeGU=c1SmH-oTy+61iHip4JKsJ0M6SRdKGBzns4Xxutg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 4, 2022 at 9:00 PM Peifeng Qiu <pgsql(at)qiupf(dot)dev> wrote:

> > the need for this code seems not that great. But as to the code itself
> I'm unable to properly judge.
> A simplified version of my use case is like this:
> CREATE FOREIGN TABLE ft(rawdata json);
> INSERT INTO tbl SELECT (convert_func(rawdata)).* FROM ft;
>
>
Which is properly written as the following, using lateral, which also
avoids the problem you describe:

INSERT INTO tbl
SELECT func_call.*
FROM ft
JOIN LATERAL convert_func(ft.rawdata) AS func_call ON true;

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-12-05 04:11:46 Re: Bug in row_number() optimization
Previous Message Peifeng Qiu 2022-12-05 04:00:37 Re: Optimize common expressions in projection evaluation