Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMPJO-0000an-Gl for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2014 22:33:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XMPJN-0000aJ-OX for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2014 22:33:57 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XMPJM-0000a8-C7 for pgsql-performance@postgresql.org; Tue, 26 Aug 2014 22:33:56 +0000 Received: from nm25-vm6.bullet.mail.ne1.yahoo.com ([98.138.91.118]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMPJH-0000fn-1c for pgsql-performance@postgresql.org; Tue, 26 Aug 2014 22:33:54 +0000 Received: from [98.138.100.115] by nm25.bullet.mail.ne1.yahoo.com with NNFMP; 26 Aug 2014 22:33:48 -0000 Received: from [98.138.87.10] by tm106.bullet.mail.ne1.yahoo.com with NNFMP; 26 Aug 2014 22:33:48 -0000 Received: from [127.0.0.1] by omp1010.mail.ne1.yahoo.com with NNFMP; 26 Aug 2014 22:33:48 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 436508.19421.bm@omp1010.mail.ne1.yahoo.com Received: (qmail 11390 invoked by uid 60001); 26 Aug 2014 22:33:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1409092428; bh=zsnwVNDD1L7MbC89cYJBV4Cv3zCrGPJbmHsZP+imeB4=; h=References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=rYv4hrnjVdhEV8aXE2CU5jX5VgRjaTOJlcKAGCux4/0BYC04JmDfqaa8UXCNWzyPou66xml3/j0g5QXm9Bsyv1o5Ev6Z1j1zOg+fVEkwuHWVut01Kj68TLzzNI2FUi5oyJxXsz2zV+2vefr+uixp576Bd7dVhP9/p0W3NZZQwK4= X-YMail-OSG: bKwOjBIVM1kjc5VHwxOPrjxXYDV8qDG0f1ScNWYZxhoZi05 makZWGkw9WG.WKelQKK_cu05DcsctH2v9huXhwR5n0G.8RJRY.P1PPBf7x1C 1GXtJS2yZuPCYukGrcOGlCc4TClYksqfY__9K3p5ui31o72SiC4AhzT.FoId yv_8ZqMDNAMeiL99aEMZB.GRW2AaaNqmwXsImYKMjjXbUeCtG5HSmReLfu8T KXdTn9HRq0ItjMZfX82J4x__BD0F96JVMkDBjipgYfufPE4vfbTJD2MxX9h7 kCvsg8Dv3u_C2OIZMNd9CHZSXWJfJoIJdqzdAgusVIJElfSB0lpWLWuKwMVe j3zPK8bWJf5pSRScG2sryRNHj2x3sViz9_BanpWYDtvLzqEA4vH5Xuuy3D.p wOff7V7Q7UBgTWjFryNfZwAEIe.eWqOT.Fwi53CTHW1016gq4BXA4y_GSEBn 0ar77oBw_WRNAfG2t9ZiIWDGP5QUfAvhCMm_BnciGFOknJi3mQZvJdQ_70ha sEeM1.jdgVAH3Oxr44uEheRRy4FlgUS.O25LKqk3JjI_dcwXqp1k2lnJurNp 7QfbyTd_69mDzSIq9EArUgdG8AYvAUmvGMvxfbNr5KoMoP.b5ox41sOQUcQ. GoyRENf7vIiT44xECC9RDaHjFTY.RdHm6vmTZ Received: from [24.178.25.147] by web122306.mail.ne1.yahoo.com via HTTP; Tue, 26 Aug 2014 15:33:48 PDT X-Rocket-MIMEInfo: 002.001, QWxleCBHb25jaGFyb3YgPGFsZXguZ29uY2hhcm92LnVzYUBnbWFpbC5jb20.IHdyb3RlOgoKPiBTdXBwb3NlIEkgQ09QWSBhIGh1Z2UgYW1vdW50IG9mIGRhdGEsIGUuZy4gMTAwIHJlY29yZHMuCj4KPiBNeSA5OSByZWNvcmRzIGFyZSBmaW5lIGZvciB0aGUgdGFyZ2V0LCBhbmQgdGhlIDEwMC10aCBpcyBub3QgLS0KPiBpdCBjb21lcyB3aXRoIGEgd3JvbmcgcmVjb3JkIGZvcm1hdCBvciBhIHRhcmdldCBjb25zdHJhaW50Cj4gdmlvbGF0aW9uLgo.Cj4gVGhlIHdob2xlIHRoaW5nIGlzIGFib3J0ZWQgdGhlbiwBMAEBAQE- X-Mailer: YahooMailWebService/0.8.201.700 References: <53F7ACF4.1010604@encs.concordia.ca> Message-ID: <1409092428.41025.YahooMailNeo@web122306.mail.ne1.yahoo.com> Date: Tue, 26 Aug 2014 15:33:48 -0700 From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: autocommit (true/false) for more than 1 million records To: Alex Goncharov , "pgsql-performance@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Pg-Spam-Score: -2.0 (--) 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 Alex Goncharov wrote: > Suppose I COPY a huge amount of data, e.g. 100 records. > > My 99 records are fine for the target, and the 100-th is not -- > it comes with a wrong record format or a target constraint > violation. > > The whole thing is aborted then, and the good 99 records are not > making it into the target table. Right. This is one reason people often batch such copies or check the data very closely before copying in. > My question is: Where are these 99 records have been living, on > the database server, while the 100-th one hasn't come yet, and > the need to throw the previous data accumulation away has not > come yet? They will have been written into the table. They do not become visible to any other transaction until and unless the inserting transaction successfully commits. These slides may help: http://momjian.us/main/writings/pgsql/mvcc.pdf > There have to be some limits to the space and/or counts taken by > the new, uncommitted, data, while the COPY operation is still in > progress. What are they? Primarily disk space for the table. If you are not taking advantage of the "unlogged load" optimization, you will have written Write Ahead Log (WAL) records, too -- which (depending on your configuration) you may be archiving. In that case, you may need to be concerned about the archive space required. If you have foreign keys defined for the table, you may get into trouble on the RAM used to track pending checks for those constraints. I would recommend adding any FKs after you are done with the big bulk load. PostgreSQL does *not* have a "rollback log" which will impose a limit. > Say, I am COPYing 100 TB of data and the bad records are close > to the end of the feed -- how will this all error out? The rows will all be in the table, but not visible to any other transaction. Autovacuum will clean them out in the background, but if you want to restart your load against an empty table it might be a good idea to TRUNCATE that table; it will be a lot faster. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance