Re: Optimize common expressions in projection evaluation - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Optimize common expressions in projection evaluation
Date
Msg-id CAKFQuwYeGU=c1SmH-oTy+61iHip4JKsJ0M6SRdKGBzns4Xxutg@mail.gmail.com
Whole thread Raw
In response to Re: Optimize common expressions in projection evaluation  (Peifeng Qiu <pgsql@qiupf.dev>)
List pgsql-hackers
On Sun, Dec 4, 2022 at 9:00 PM Peifeng Qiu <pgsql@qiupf.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.

pgsql-hackers by date:

Previous
From: Peifeng Qiu
Date:
Subject: Re: Optimize common expressions in projection evaluation
Next
From: David Rowley
Date:
Subject: Re: Bug in row_number() optimization