Re: [PATCH] Add support for INSERT ... SET syntax

From: Suraj Kharage <suraj(dot)kharage(at)enterprisedb(dot)com>
To: Maxim Orlov <orlovmg(at)gmail(dot)com>
Cc: Mario González <gonzalemario(at)gmail(dot)com>, Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add support for INSERT ... SET syntax
Date: 2026-12-03 13:02:02
Message-ID: CAF1DzPXojjeKp9pL6ENRV0PupxAv_rFPQXkpuFCtyBLJpq1xUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 23, 2026 at 6:14 PM Maxim Orlov <orlovmg(at)gmail(dot)com> wrote:

> Hi!
>
> I want to say right away that I like the idea behind the patch.
>
> One area I noticed is in transformInsertSetClause. This call uses nested
> loops to construct lists. In a synthetic test case with a thousand
> columns and many records, the patch performs significantly slower than
> a standard INSERT. It might be possible to use a hash table to speed up
> lookups in this scenario. On the other hand, that would also make the
> code a bit more complicated.
>
> I don’t consider this a flaw of some sort, that should hold up
> development or committing the code—it’s simply a characteristic worth
> being aware of.
>
>
Thank you for the review.

Following your suggestion, I implemented the hash table approach in
transformInsertSetClause, and it does turn out to be faster. Since this
is the INSERT path, I think performance is important here.
Please find attached the v8 patch that implements the hash table approach.

I have also performed a quick perforamnce test for the same and I
can see good amount of improvement if we have large number of columns.
These numbers are in milliseconds.

rows x columns v7 (list scan) v8 (hash table)
--------------------- -------------- ---------------
10 rows x 10 cols 0.06 0.06
1000 rows x 10 cols 2.38 2.26
100 rows x 100 cols 4.25 2.15
1000 rows x 100 cols 43.5 22.4
10 rows x 1000 cols 28.9 3.69
100 rows x 1000 cols 274.9 24.5
1000 rows x 1000 cols 2789 236.7

Please let me know your thoughts on the same.
--

Thanks & Regards,
Suraj kharage,

enterprisedb.com <https://www.enterprisedb.com/>

Attachment Content-Type Size
v8-0001-Add-support-for-INSERT-.-SET-syntax.patch application/octet-stream 51.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2026-12-03 13:08:14 Re: Use local buffer for packed numerics
Previous Message Jeevan Chalke 2026-12-03 12:52:30 CRASH: use-after-free of function stats when a procedure rolls back its own CREATE