Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z20dZ-0001Er-Ab for pgsql-jdbc@arkaria.postgresql.org; Mon, 08 Jun 2015 17:15:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z20dY-0005RM-1J for pgsql-jdbc@arkaria.postgresql.org; Mon, 08 Jun 2015 17:15:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z20dQ-0005G3-Pz for pgsql-jdbc@postgresql.org; Mon, 08 Jun 2015 17:14:53 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z20dM-00052R-Kd for pgsql-jdbc@postgresql.org; Mon, 08 Jun 2015 17:14:50 +0000 Received: by wibut5 with SMTP id ut5so93258873wib.1 for ; Mon, 08 Jun 2015 10:14:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=6HbJ8dhaTD8kfjngYMgXvWBhPW/9M3QFGW1o0uhgwXE=; b=IKyJQ0kn2K9eeiYP6zJxAEnEysbpU5nIaeG656c2wj1pXkZoBWo5KsX7ksh/Ayjqk+ PkB4Ve1hFclObRAX8Gkm3YrIs+RgQY2do1CyzjU7RWg39k9O5WSjhHUtmBbMkz3lQPnR 72UtcH2IzZXDYnV9rprD4z3vFCJznUhRpIlbJalGvEsAW97hdhc9GsxH7OUDEfskCLTB w96Q0YZBkUuaEoinkfSt5mFfVxqHIxS1QR6Rcw5fCqEX1T4NTx2lVAmdKwega61WtWA2 vqHgIGZvKEcuG9DyDGu+M2W+4jGnnmP2JhhHXiq+jYt+BgO1DYGDKdHea6dt9ypg4wxd U3rw== X-Gm-Message-State: ALoCoQm9RJRhSNZ7QQkSEXAHxutVyn9A3hqX6GC+lBRdDfb3DEAsqGfwx3z4+pcn/F0UwkfEH93g X-Received: by 10.194.238.193 with SMTP id vm1mr34111255wjc.57.1433783686809; Mon, 08 Jun 2015 10:14:46 -0700 (PDT) Received: from [192.168.43.95] ([31.4.239.193]) by mx.google.com with ESMTPSA id u13sm5285527wjw.37.2015.06.08.10.14.44 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Jun 2015 10:14:45 -0700 (PDT) Message-ID: <5575CD83.4010501@8Kdata.com> Date: Mon, 08 Jun 2015 13:14:43 -0400 From: =?UTF-8?B?w4FsdmFybyBIZXJuw6FuZGV6IFRvcnRvc2E=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Robert DiFalco , jaime.soler@gmail.com CC: Dave Cramer , Vitalii Tymchyshyn , List Subject: Re: Multiple Row Insert vs. Batch References: <33CACA06-F1A0-466B-B985-D33ACA15A984@gmail.com> <1433755648.2994.10.camel@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000905080204010502020809" X-Pg-Spam-Score: -1.8 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------000905080204010502020809 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Robert. That sounds interesting. Is your test code published / publishable, for peer review? Are you using jmh or any similar tool for conducting the test? Have you considering throwing latency measures into the test (where hdrhistogram may be a great helper). Sorry for asking too many questions, but I hope they help :) Regards, -- Álvaro Hernández Tortosa ----------- 8Kdata On 08/06/15 12:29, Robert DiFalco wrote: > To make it apples to apples I included the time to transform the > payload. It's maybe 1-4% faster for 250 rows with 3 fields sampled 100 > times with a JVM warm-up. > > On Mon, Jun 8, 2015 at 2:27 AM, jaime soler > wrote: > > 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 > > > 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 > > > 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 > > > 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 > > > > 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 > > > > пише: > > > > > > 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 > > > > > wrote: > > > Say I need to insert 250 > > > rows. Is single-statement > > > multiple row insert or JDBC > > > batch likely to be faster? > > > > > > > > > Thanks! > > > > > > > > > R. > > > > > > > > > > > > > > > > > > > > > > > -- Álvaro Hernández Tortosa ----------- 8Kdata --------------000905080204010502020809 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
    Hi Robert.

    That sounds interesting. Is your test code published / publishable, for peer review? Are you using jmh or any similar tool for conducting the test? Have you considering throwing latency measures into the test (where hdrhistogram may be a great helper).

    Sorry for asking too many questions, but I hope they help :)

    Regards,

   
-- 
Álvaro Hernández Tortosa


-----------
8Kdata

On 08/06/15 12:29, Robert DiFalco wrote:
To make it apples to apples I included the time to transform the payload. It's maybe 1-4% faster for 250 rows with 3 fields sampled 100 times with a JVM warm-up.

On Mon, Jun 8, 2015 at 2:27 AM, jaime soler <jaime.soler@gmail.com> wrote:
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.
>                 >
>                 >
>                 >
>                 >
>
>
>
>




-- 
Álvaro Hernández Tortosa


-----------
8Kdata

--------------000905080204010502020809--