Re: Optimize common expressions in projection evaluation

2022-12-05 Thread Peifeng Qiu
> 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; I didn't fully realize this syntax until you point out. Just try it out in ou

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread David G. Johnston
On Sun, Dec 4, 2022 at 9:37 PM Pavel Stehule wrote: > > po 5. 12. 2022 v 5:28 odesílatel Tom Lane napsal: > >> Peifeng Qiu writes: >> >> the need for this code seems not that great. But as to the code >> itself I'm unable to properly judge. >> >> I mention this because trying to reverse-engine

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread Tom Lane
Pavel Stehule writes: > po 5. 12. 2022 v 5:28 odesílatel Tom Lane napsal: >> I tend to agree with David that LATERAL offers a good-enough >> solution in most cases ... but it is annoying that we accept >> this syntax and then pessimize it. > I agree, so there is a perfect solution like don't use

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread Pavel Stehule
po 5. 12. 2022 v 5:28 odesílatel Tom Lane napsal: > Peifeng Qiu writes: > >> 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

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread Tom Lane
Peifeng Qiu writes: >> 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; It might be wo

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread David G. Johnston
On Sun, Dec 4, 2022 at 9:00 PM Peifeng Qiu 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

Re: Optimize common expressions in projection evaluation

2022-12-04 Thread Peifeng Qiu
> 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; We have a foreign data source that can emit j

Re: Optimize common expressions in projection evaluation

2022-12-02 Thread David G. Johnston
On Fri, Dec 2, 2022 at 12:52 AM Peifeng Qiu wrote: > Hi hackers. > > When a star(*) expands into multiple fields, our current > implementation is to generate multiple copies of the expression > and do FieldSelects. This is very inefficient because the same > expression get evaluated multiple time

Optimize common expressions in projection evaluation

2022-12-01 Thread Peifeng Qiu
regards, Peifeng Qiu From 52b389466cf397c6e70168a64252abf4c7453ba6 Mon Sep 17 00:00:00 2001 From: Peifeng Qiu Date: Fri, 2 Dec 2022 16:37:03 +0900 Subject: [PATCH] Optimize common expressions in projection evaluation When a star(*) expands into multiple fields, our current implementation is to generate multiple copies