COPY performance vs insert

Started by PG Bug reporting formabout 6 years ago2 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/populate.html
Description:

I think this could be clearer. In particular, performance of COPY vs INSERT
from a query (INSERT INTO ... SELECT FROM ...) or INSERT with a list of rows
(INSERT INTO ... VALUES (), (), (), ...)
Is there any performance benefit with COPY in those cases?

#2Bruce Momjian
bruce@momjian.us
In reply to: PG Bug reporting form (#1)
Re: COPY performance vs insert

On Wed, Feb 12, 2020 at 09:25:05AM +0000, PG Doc comments form wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/populate.html
Description:

I think this could be clearer. In particular, performance of COPY vs INSERT
from a query (INSERT INTO ... SELECT FROM ...) or INSERT with a list of rows
(INSERT INTO ... VALUES (), (), (), ...)
Is there any performance benefit with COPY in those cases?

COPY input/outputs rows in bulk, so it is still faster to do COPY than
INSERT INTO ... SELECT FROM or INSERT INTO ... VALUES. You can run
tests to prove it.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +