Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z1tLL-00076x-Pi for pgsql-jdbc@arkaria.postgresql.org; Mon, 08 Jun 2015 09:27:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z1tLK-00007e-4F for pgsql-jdbc@arkaria.postgresql.org; Mon, 08 Jun 2015 09:27:42 +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 1Z1tLJ-00007W-Bu for pgsql-jdbc@postgresql.org; Mon, 08 Jun 2015 09:27:41 +0000 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z1tLF-0004Hy-Ke for pgsql-jdbc@postgresql.org; Mon, 08 Jun 2015 09:27:39 +0000 Received: by wiga1 with SMTP id a1so79263208wig.0 for ; Mon, 08 Jun 2015 02:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:reply-to:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=Uo6O96i8nd6bUw/3jw4abOKWZa6n/BvtqRQ9eVjI7gc=; b=DL9fTpNud5aMlbiJnMasCXLiEK2ExXj1t4ZLLv9CbPY35N1I5znRIdqUwkzLuKHCQ5 yKreAZx3f3N4IX58IPnP8L5E07sW6Yzk5byUMALI6XhO5xH4sZYqnNi3hygSBPwumHX0 ykjYl73XbNpND93qL2oRKMAedS8Q3XOGLpUYIlbul61kPtnlLpOiqQhTKRsUjb6NFMuc 9oOgtwphWuOJz1kTMParyvbI+d5yhj8bcwA6YhJMiB8so405V684yM4iQransrj29swi 1LCDa/oLkDBILY23zYtuJsr40lq3E8AJFkujRxSovtxqEG/ZUYPuwC0ykZXhyh7PQba5 ANQg== X-Received: by 10.194.186.198 with SMTP id fm6mr30788904wjc.101.1433755656247; Mon, 08 Jun 2015 02:27:36 -0700 (PDT) Received: from enterprisedb01 (213.37.154.13.static.user.ono.com. [213.37.154.13]) by mx.google.com with ESMTPSA id o4sm50727wib.5.2015.06.08.02.27.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jun 2015 02:27:35 -0700 (PDT) Message-ID: <1433755648.2994.10.camel@gmail.com> Subject: Re: Multiple Row Insert vs. Batch From: jaime soler Reply-To: jaime.soler@gmail.com To: Robert DiFalco Cc: Dave Cramer , Vitalii Tymchyshyn , List Date: Mon, 08 Jun 2015 11:27:28 +0200 In-Reply-To: References: <33CACA06-F1A0-466B-B985-D33ACA15A984@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) 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 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. > > > > > > > > > > > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc