Re: Make COPY format extendable: Extract COPY TO format implementations
Sutou Kouhei <kou@clear-code.com>
Attachments
- (unnamed) (text/plain)
- mac-mini-result-1.csv (text/csv)
- mac-mini-result-1.pdf (application/pdf)
- mac-mini-result-2.csv (text/csv)
- mac-mini-result-2.pdf (application/pdf)
- mac-mini-result-3.csv (text/csv)
- mac-mini-result-3.pdf (application/pdf)
- mac-mini-result-4.csv (text/csv)
- mac-mini-result-4.pdf (application/pdf)
- mac-mini-result-5.csv (text/csv)
- mac-mini-result-5.pdf (application/pdf)
- mac-mini-result-6.csv (text/csv)
- mac-mini-result-6.pdf (application/pdf)
Hi,
In <c36d218a-bb38-42b9-9076-cb75b8984a39@vondra.me>
"Re: Make COPY format extendable: Extract COPY TO format implementations" on Mon, 17 Nov 2025 18:04:46 +0100,
Tomas Vondra <tomas@vondra.me> wrote:
> I got pinged about this patch off-list. I won't have capacity to do a
> proper review, anytime soon, but I got a bit of time to do a simple
> benchmark (which seems useful as that was one of the concerns in this
> thread, it seems).
Thanks!!!
I also do the same condition benchmark on my Mac mini:
Machine:
* Apple M1 (8 core)
* Memory: 16GB
* macOS Sequoia (15.6)
Parameters:
* N integer columns: 1 10 100
* N rows: 10 100 1000 10000 10000 100000 1000000
* Formats: text csv binary
* Operations: FROM TO
* Patches: 0001 0002 0003 0004 0005 0006
I ran 5 times for each parameter set and choose the median
elapsed time.
I used
https://gitlab.com/ktou/pg-bench/-/blob/main/copy-format-extendable/run.sh
. I attach it.
I measured 6 times. See the attached mac-mini-result-${N}.{csv,pdf}.
A PDF has 3 columns. They are text, csv and binary formats
from left to right.
1st row uses COPY FROM and 0001 patch.
2nd row uses COPY TO and 0001 patch.
3rd row uses COPY FROM and 0002 patch.
4th row uses COPY TO and 0002 patch.
...
Each heatmap visualizes (${elapsed_time_patch} /
${elapsed_time_master}) * 100. 100 > (red) means slower and
100 < (blue) means faster.
It seems that they don't show any reproducible trends.
For example, the binary cases in mac-mini-result-2.pdf show
that patched cases are always slower but the binary cases in
mac-mini-result-{1,6}.pdf show that most patched cases are
faster. The binary cases in mac-mini-result-{1,5,6}.pdf show
that 0006 patch is slower than 0005 patch but the binary
cases in mac-mini-result-{3,4}.pdf don't show it.
Another example, the text cases in mac-mini-result-1.pdf
show that patched cases are always slower but the text cases
in mac-mini-result-1.pdf show that most patched cases are
faster.
I hope that these numbers help to proceed this proposal.
Thanks,
--
kou
Commits
-
Refactor Copy{From|To}GetRoutine() to use pass-by-reference argument.
- bacbc4863b3b 18.0 landed
-
Refactor COPY FROM to use format callback functions.
- 7717f6300693 18.0 landed
-
Refactor COPY TO to use format callback functions.
- 2e4127b6d2d8 18.0 landed
-
Another try to fix BF failure introduced in commit ddd5f4f54a.
- 9bc1eee988c3 17.0 cited
-
Revert "Refactor CopyReadAttributes{CSV,Text}() to use a callback in COPY FROM"
- 06bd311bce24 17.0 landed
-
Improve COPY TO performance when server and client encodings match
- b619852086ed 17.0 cited
-
Simplify signature of CopyAttributeOutCSV() in copyto.c
- b9d6038d7048 17.0 landed
-
Revert "Refactor CopyAttributeOut{CSV,Text}() to use a callback in COPY TO"
- 1aa8324b81fa 17.0 landed
-
Refactor CopyAttributeOut{CSV,Text}() to use a callback in COPY TO
- 2889fd23be56 17.0 landed
-
Refactor CopyReadAttributes{CSV,Text}() to use a callback in COPY FROM
- 95fb5b49024a 17.0 landed
-
Add progress reporting of skipped tuples during COPY FROM.
- 729439607ad2 17.0 cited
-
pgbench: Add \syncpipeline
- 94edfe250c6a 17.0 cited
-
meson: Make gzip and tar optional
- 9ca6e7b9411e 17.0 cited
-
Export the external file reader used in COPY FROM as APIs.
- 8ddc05fb01ee 9.1.0 cited