Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XKw79-0006Q0-Af for pgsql-performance@arkaria.postgresql.org; Fri, 22 Aug 2014 21:11:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XKw78-0008IL-5P for pgsql-performance@arkaria.postgresql.org; Fri, 22 Aug 2014 21:11:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XKw77-0008IE-2M for pgsql-performance@postgresql.org; Fri, 22 Aug 2014 21:11:13 +0000 Received: from oldperseverance.encs.concordia.ca ([132.205.96.92]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XKw6y-0001dH-Ip for pgsql-performance@postgresql.org; Fri, 22 Aug 2014 21:11:12 +0000 Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by oldperseverance.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id s7MLB1jM007549; Fri, 22 Aug 2014 17:11:01 -0400 Message-ID: <53F7B1E5.6030507@encs.concordia.ca> Date: Fri, 22 Aug 2014 17:11:01 -0400 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org CC: sfrost@snowman.net, david.g.johnston@gmail.com Subject: Re: autocommit (true/false) for more than 1 million records References: <53F7ACF4.1010604@encs.concordia.ca> <20140822210018.GZ16422@tamriel.snowman.net> In-Reply-To: <20140822210018.GZ16422@tamriel.snowman.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on oldperseverance.encs.concordia.ca at 2014/08/22 17:11:01 EDT X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org > * >> 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) > It depends on what you need. > > Data will be available to concurrent processes earlier with (1), while > (2) will go faster. No need to worry about the lock/loosing records because after data loading will do a check. For now, I'd like the fastest way. Would you suggest commit every 1000 or 3000 records? Thanks a lot! Emi -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance