Re: COPY and heap_sync

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY and heap_sync
Date: 2014-09-02 15:41:22
Message-ID: CAMkU=1zOi9Npj8He8EOuMAgH-Sb2k_i5KoKoauqmpvwRFuE3Nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 31, 2014 at 6:10 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On 8/30/14 2:26 AM, Jeff Janes wrote:
> > But there cases were people use COPY in a loop with a small amount of
> > data in each statement.
>
> What would be the reason for doing that?
>
>
As far as I can tell, DRY. They need code to do bulk inserts anyway. So,
just use that everywhere even when it is not in bulk.

Also, you can't interleave a copy command with other queries on the same
connection. So you code it to start a COPY, use it until you discover you
need to run a query (because you encounter something not in you local
cache), end the COPY and do that query, then restart the query.

Under some conditions, the interruption occurs very seldom, under other
conditions it is pretty much every row.

Cheers,

Jeff

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2014-09-02 15:44:22 Re: PL/pgSQL 2
Previous Message Jeff Janes 2014-09-02 15:36:19 Re: postgresql latency & bgwriter not doing its job