Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibDWu-0001gt-Ku for pgsql-docs@arkaria.postgresql.org; Sun, 01 Dec 2019 00:56:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ibDWt-00035z-3I for pgsql-docs@arkaria.postgresql.org; Sun, 01 Dec 2019 00:56:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibDWs-00035j-S6 for pgsql-docs@lists.postgresql.org; Sun, 01 Dec 2019 00:56:02 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibDWk-0007AI-Jj for pgsql-docs@lists.postgresql.org; Sun, 01 Dec 2019 00:56:01 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1ibDWg-0004U4-FC; Sat, 30 Nov 2019 19:55:50 -0500 Date: Sat, 30 Nov 2019 19:55:50 -0500 From: Bruce Momjian To: Laurenz Albe Cc: mayank.l.patel90@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: Difference between Bulk Load (Multiple inserts or single inserts) and COPY Message-ID: <20191201005550.GC4326@momjian.us> References: <157418972366.28426.16885409770050714771@wrigleys.postgresql.org> <41b4852ea43e59969cfefaf37c4578a23000075b.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41b4852ea43e59969cfefaf37c4578a23000075b.camel@cybertec.at> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Nov 19, 2019 at 11:55:44PM +0100, Laurenz Albe wrote: > On Tue, 2019-11-19 at 18:55 +0000, PG Doc comments form wrote: > > I experimented with Bulk load and COPY. > > Loading in COPY was very fast. > > However, after COPYing data from a CSV file to PostgreSQL Table. The query > > execution took lot of time for 1 of the first 4 queries. > > Only this slow query was taking so much time, that even if I had used normal > > bulk load, it would have been faster in total. > > Then all other Query executions took equal time as it took while querying a > > table after the Bulk data load method. > > > > So, I want to know the exact reason what's the issue with COPY. > > How exactly they differ? The only thing from the document I could identify > > was row security. > > But it did not mention anything about indexing. Like, in Bulk load, do > > indices(or constraint checks) are created with data loading? > > & in COPY it's done after? so when indices are being created that query > > slows down?? > > > > Please reply soon with more details or send a link where I can read it in > > depth. > > That cannot be answered without knowing the exact statements and the > table definitions. I wonder if it is the overhead of rewriting all the rows to set the per-row HEAP_XMIN_COMMITTED bit. Unfortunately, I don't know a way to test this hypothesis. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +