Re: COPY performance vs insert

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: colinthart(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: COPY performance vs insert
Date: 2020-03-17 21:02:25
Message-ID: 20200317210225.GA17915@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

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(at)momjian(dot)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 +

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2020-03-17 21:21:36 Re: pg_buffercache query example results misleading, grouping by just relname, needs schema_name
Previous Message Bruce Momjian 2020-03-16 20:47:53 Re: 9.4. String Functions and Operators page does not document that encode adds line breaks