Re: COPY vs INSERT

From: Kris Jurka <books(at)ejurka(dot)com>
To: Mischa Sandberg <mischa(dot)sandberg(at)telus(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: COPY vs INSERT
Date: 2005-05-04 23:33:50
Message-ID: Pine.BSO.4.56.0505041817480.2683@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 4 May 2005, Mischa Sandberg wrote:

> Copy makes better use of the TCP connection for transmission. COPY uses
> the TCP connection like a one-way pipe. INSERT is like an RPC: the
> sender has to wait until the insert's return status roundtrips.

Not true. A client may send any number of Bind/Execute messages on a
prepared statement before a Sync message. So multiple inserts may be sent
in one network roundtrip. This is exactly how the JDBC driver
implements batch statements. There is some limit to the number of queries
in flight at any given moment because there is the potential to deadlock
if both sides of network buffers are filled up and each side is blocked
waiting on a write. The JDBC driver has conservatively selected 256 as
the maximum number of queries to send at once.

Kris Jurka

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-05-05 01:51:22 Re: COPY vs INSERT
Previous Message Christopher Petrilli 2005-05-04 23:29:29 Re: COPY vs INSERT