| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Tomás Senart <ts(at)perfloop(dot)ai> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH v1] Avoid deforming unused trailing columns in COPY TO |
| Date: | 2026-11-19 01:44:32 |
| Message-ID: | 4401F3C1-8330-4B2B-BD8D-C9A1F0E4316B@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Nov 19, 2026, at 04:52, Tomás Senart <ts(at)perfloop(dot)ai> wrote:
>
> Hi Chao,
>
> Thanks for the review. Both points are right, and v2 attached does both.
>
> 1. max_attnum is now an AttrNumber placed after the two bool fields,
> so it fits in the existing padding and CopyToStateData does not grow.
> 2. The slot_getsomeattrs() call in the else branch is gone.
> CopyOneRowTo() already deforms the needed prefix, so that branch now
> only sets copyslot = slot.
>
> With assertions enabled, the regress suite (243 tests) and the
> subscription TAP tests, including 031_column_list, pass. The code
> change is otherwise the same as v1.
>
> Regards,
> Tomás
> <v2-0001-Avoid-deforming-unused-trailing-columns-in-COPY-T.patch>
V2 looks good to me.
I just ran a simple performance test on my MacBook M4 with a 50-column table containing 1 million rows, copying the first 3 columns, middle 3 columns, and last 3 columns. The test shows some improvements:
```
Master (091b2926044) v2
First 3 columns 155ms 133ms
Middle 3 columns 156ms 140ms
Last 3 columns 157ms 159ms
```
The durations shown in the table are averages from multiple runs. The tests were run with builds that had assertions and debugging disabled.
We can see that copying the first 3 columns and middle 3 columns shows a noticeable performance improvement. When copying the last 3 columns, there is little difference before and after the patch.
I ran the tests with builds disabling asserts and debug.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joao Rito | 2026-11-19 01:45:13 | [PATCH] pg_createsubscriber: add hint to wal_level error |
| Previous Message | Bharath Rupireddy | 2026-11-19 01:38:38 | Re: pg_xmin_horizon: a system view of everything pinning the xmin horizon |