From: jaime soler <jaime.soler@gmail.com>
To: Robert DiFalco <robert.difalco@gmail.com>
Cc: Dave Cramer <pg@fastcrypt.com>
Cc: Vitalii Tymchyshyn <vit@tym.im>
Cc: List <pgsql-jdbc@postgresql.org>
Subject: Re: Multiple Row Insert vs. Batch
Date: Mon, 08 Jun 2015 11:27:28 +0200
Message-ID: <1433755648.2994.10.camel@gmail.com> (raw)
In-Reply-To: <CAAXGW-xneC+FPc0r_JpJS3ubijH0Gee4ZpAoYkWMmkXYpdxK3Q@mail.gmail.com>
References: <CAAXGW-yACAgMsW+qikxPJq_6Dn_jZxbygM7h6FdT3foDce3pvw@mail.gmail.com>
<CADK3HHK3GGaEjCyPStaFx0MqBvJ07uB2bH-wmgLUkrpAsEASuQ@mail.gmail.com>
<CABWW-d1=T9jUQu+7wdc62vzuQ20Wkw2nRcXJcyXQK9pGPdZZHg@mail.gmail.com>
<CADK3HHJF4RbCiL9xbnrEArVPh1PtLcPd3wjRSw5PPEeKqtnveg@mail.gmail.com>
<33CACA06-F1A0-466B-B985-D33ACA15A984@gmail.com>
<CAAXGW-zUpAc5XaAi-Rm0o=zMY8a=DwscHzntSJtJkX7f2oXXaw@mail.gmail.com>
<CAAXGW-xneC+FPc0r_JpJS3ubijH0Gee4ZpAoYkWMmkXYpdxK3Q@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
El dom, 07-06-2015 a las 09:56 -0700, Robert DiFalco escribió:
> Another interesting thing is that for 250 records COPY is actually the
> slowest. But these are real world tests to that could have been the
> time it took to transform the 250 records to CSV.
Hi Robert,
Copy using
CopyManager( https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html ) should be faster than multi-row inserts and batch single-row insert. Did you count only the copy time without transformation time ?
>
> On Sun, Jun 7, 2015 at 9:41 AM, Robert DiFalco
> <robert.difalco@gmail.com> wrote:
> I did a benchmark and multi-row insert with a single statement
> is about 6-7% faster than batch insert. This is for 250 rows
> executed a thousand times in a loop (alternating between the
> two to reduce subsequent table insert index slowdown). So a
> little faster but not significantly so.
>
> On Sat, Jun 6, 2015 at 12:07 PM, Robert DiFalco
> <robert.difalco@gmail.com> wrote:
> Yes that's correct. A multiple row insert with a
> single insert statement. I'll try benchmarking the two
> on Monday. My guess is that they are pretty damn
> similar.
>
> Sent from my iPhone
>
> On Jun 6, 2015, at 10:35 AM, Dave Cramer
> <pg@fastcrypt.com> wrote:
>
>
> > Robert ??
> >
> >
> > Is that what you meant ?
> >
> > Dave Cramer
> >
> > dave.cramer(at)credativ(dot)ca
> > http://www.credativ.ca
> >
> >
> > On 6 June 2015 at 13:34, Vitalii Tymchyshyn
> > <vit@tym.im> wrote:
> > I think OP meant something like
> > Insert into table values
> > (?,?,?),(?,?,?),...,(?,?,?);
> > Vs batch of insert into table values(?,?,?);
> >
> > I really think first would be faster up to a
> > certain amount of rows, but test is needed
> > to check.
> >
> > Vitalii Tymchyshyn
> >
> >
> >
> > Сб, 6 черв. 2015 13:30 Dave Cramer
> > <pg@fastcrypt.com> пише:
> >
> > batch should be faster and if it
> > isn't we did something wrong
> >
> > Dave Cramer
> >
> > dave.cramer(at)credativ(dot)ca
> > http://www.credativ.ca
> >
> >
> > On 6 June 2015 at 12:34, Robert
> > DiFalco <robert.difalco@gmail.com>
> > wrote:
> > Say I need to insert 250
> > rows. Is single-statement
> > multiple row insert or JDBC
> > batch likely to be faster?
> >
> >
> > Thanks!
> >
> >
> > R.
> >
> >
> >
> >
>
>
>
>
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: jaime.soler@gmail.com, robert.difalco@gmail.com, pg@fastcrypt.com, vit@tym.im
Subject: Re: Multiple Row Insert vs. Batch
In-Reply-To: <1433755648.2994.10.camel@gmail.com>
References: <CAAXGW-yACAgMsW+qikxPJq_6Dn_jZxbygM7h6FdT3foDce3pvw@mail.gmail.com> <CADK3HHK3GGaEjCyPStaFx0MqBvJ07uB2bH-wmgLUkrpAsEASuQ@mail.gmail.com> <CABWW-d1=T9jUQu+7wdc62vzuQ20Wkw2nRcXJcyXQK9pGPdZZHg@mail.gmail.com> <CADK3HHJF4RbCiL9xbnrEArVPh1PtLcPd3wjRSw5PPEeKqtnveg@mail.gmail.com> <33CACA06-F1A0-466B-B985-D33ACA15A984@gmail.com> <CAAXGW-zUpAc5XaAi-Rm0o=zMY8a=DwscHzntSJtJkX7f2oXXaw@mail.gmail.com> <CAAXGW-xneC+FPc0r_JpJS3ubijH0Gee4ZpAoYkWMmkXYpdxK3Q@mail.gmail.com> <1433755648.2994.10.camel@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox