Re: autocommit (true/false) for more than 1 million records

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: autocommit (true/false) for more than 1 million records
Date: 2014-08-25 15:48:18
Message-ID: CAMkU=1xWQdCs0nbZSXrkdK4Y7moLKWV8X60MSdDSw-oR27L7yw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Aug 22, 2014 at 1:49 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:

> Hello,
>
> Trying to insert into one table with 1 million records through java JDBC
> into psql8.3. May I know (1) or (2) is better please?
>
> (1) set autocommit(true)
> (2) set autocommit(false)
> commit every n records (e.g., 100, 500, 1000, etc)
>

In general it is better to use COPY (however JDBC for 8.3. exposes that),
as that is designed specifically for bulk loading.

Then it doesn't matter whether autocommit is on or off, because the COPY is
a single statement.

Cheers,

Jeff

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jeison Bedoya Delgado 2014-08-25 18:47:46 tuning postgresql 9.3.5 and multiple cores
Previous Message Felipe Santos 2014-08-25 14:02:52 Re: autocommit (true/false) for more than 1 million records