Skip site navigation (1) Skip section navigation (2)

Re: Multiple insert performance trick or performance misunderstanding?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Multiple insert performance trick or performance misunderstanding?
Date: 2005-09-24 21:15:41
Message-ID: 23702.1127596541@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> writes:
> Is it expected that I'd be better off sending big
> concatenated strings like
>    "insert into tbl (c1,c2) values (v1,v2);insert into tbl (c1,c2) values (v3,v4);..."
> instead of sending them one at a time?

It's certainly possible, if the network round trip from client to server
is slow.  I do not think offhand that there is any material advantage
for the processing within the server (assuming you've wrapped the whole
thing into one transaction in both cases); if anything, the
concatenated-statement case is probably a bit worse inside the server
because it will transiently eat more memory.  But network latency or
client-side per-command overhead could well cause the results you see.

			regards, tom lane

In response to

pgsql-performance by date

Next:From: Michael Ben-NesDate: 2005-09-25 10:17:27
Subject: Re: Advice on RAID card
Previous:From: Ron MayerDate: 2005-09-24 20:51:16
Subject: Multiple insert performance trick or performance misunderstanding?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group