Re: Using COPY FREEZE in pgbench

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Using COPY FREEZE in pgbench
Date: 2021-03-08 10:19:55
Message-ID: f3c820673e9cccf08b71611d44fef140954c86e9.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2021-03-08 at 14:39 +0900, Tatsuo Ishii wrote:
> Currently pgbench uses plain COPY to populate pgbench_accounts
> table. With adding FREEZE option to COPY, the time to perform "pgbench
> -i" will be significantly reduced.
>
> Curent master:
> pgbench -i -s 100
> :
> :
> done in 70.78 s (drop tables 0.21 s, create tables 0.02 s, client-side generate 12.42 s, vacuum 51.11 s, primary keys 7.02 s).
>
> Using FREEZE:
> done in 16.86 s (drop tables 0.20 s, create tables 0.01 s, client-side generate 11.86 s, vacuum 0.25 s, primary keys 4.53 s).
>
> As you can see total time drops from 70.78 seconds to 16.86 seconds,
> that is 4.1 times faster. This is mainly because vacuum takes only
> 0.25 seconds after COPY FREEZE while unpatched pgbench takes 51.11
> seconds, which is 204 times slower.
>
> Thanks for the COPY FREEZE patch recently committed:
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=7db0cd2145f2bce84cac92402e205e4d2b045bf2
>
> Attached is one line patch for this.

That is indeed low hanging fruit and an improvement.

> - res = PQexec(con, "copy pgbench_accounts from stdin");
> + res = PQexec(con, "copy pgbench_accounts from stdin freeze");

I think it would be better to use the official syntax and put the "freeze"
in parentheses. Perhaps the old syntax will be desupported some day.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Nancarrow 2021-03-08 10:24:09 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message Peter Eisentraut 2021-03-08 10:16:16 Re: Boundary value check in lazy_tid_reaped()