Re: Is it possible to make a streaming replication faster using COPY instead of lots of INSERTS?

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is it possible to make a streaming replication faster using COPY instead of lots of INSERTS?
Date: 2011-12-01 08:08:25
Message-ID: CAL_0b1uqpZFBvairfF54k-WESMac_Xhm03g_r=XO122s5k6KsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1 December 2011 04:00, David Johnston <polobo(at)yahoo(dot)com> wrote:
> On Nov 30, 2011, at 18:44, Craig Ringer <ringerc(at)ringerc(dot)id(dot)au> wrote:
>
>> On 11/30/2011 10:32 PM, Sergey Konoplev wrote:
> Insert into tbl values(...); [times 50]
> insert into tbl values (...), (...), (...), ...; [ once with 50 values ]
> Copy [ with 50 input rows provided ]
>
> I would presume the first one is badly performing but no idea whether the multi-value version of insert would be outperformed by an equivalent Copy command (both on the main query and during replication)
>
> Though, does auto-commit affect the results in the first case; I.e., without auto-commit do the first two results replicate equivalently?

So the guaranteed solutions are either

BEGIN;
INSERT INTO table1 VALUES (...), (...), ...;
COMMIT;

or

COPY FROM ...;

correct?

>
>>
> David J

--
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com
LinkedIn: http://ru.linkedin.com/in/grayhemp
JID/GTalk: gray(dot)ru(at)gmail(dot)com Skype: gray-hemp

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2011-12-01 09:34:29 Re: Strange problem with turning WAL archiving on
Previous Message Sergey Konoplev 2011-12-01 08:05:16 Re: Is it possible to make a streaming replication faster using COPY instead of lots of INSERTS?