Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XLuVO-0000Hg-3g for pgsql-performance@arkaria.postgresql.org; Mon, 25 Aug 2014 13:40:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XLuVN-0002l0-BS for pgsql-performance@arkaria.postgresql.org; Mon, 25 Aug 2014 13:40:17 +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 1XLuVM-0002kV-2C for pgsql-performance@postgresql.org; Mon, 25 Aug 2014 13:40:16 +0000 Received: from oldperseverance.encs.concordia.ca ([132.205.96.92]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XLuVH-0005d2-EH for pgsql-performance@postgresql.org; Mon, 25 Aug 2014 13:40:14 +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 s7PDe7u2019766; Mon, 25 Aug 2014 09:40:07 -0400 Message-ID: <53FB3CB7.8010104@encs.concordia.ca> Date: Mon, 25 Aug 2014 09:40:07 -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: Stephen Frost CC: pgsql-performance@postgresql.org, 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> <53F7B1E5.6030507@encs.concordia.ca> <20140822212115.GB16422@tamriel.snowman.net> In-Reply-To: <20140822212115.GB16422@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/25 09:40:07 EDT X-Pg-Spam-Score: -1.9 (-) 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 Good morning, >>>> 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? > The improvement drops off pretty quickly in my experience, but it > depends on the size of the records and other things. The table is huge with almost 170 columns. > Try it and see..? It's almost certainly going to depend on your > specific environment. Can you let me know what are the "specific environment" please? Such as: ...... By the way, could someone let me know why set autocommit(false) is for sure faster than true please? Or, some online docs talk about this. 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