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 1iXCPd-0005xK-JW for pgsql-docs@arkaria.postgresql.org; Tue, 19 Nov 2019 22:55:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iXCPb-0008Dk-VY for pgsql-docs@arkaria.postgresql.org; Tue, 19 Nov 2019 22:55:55 +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 1iXCPb-0008Dd-KD for pgsql-docs@lists.postgresql.org; Tue, 19 Nov 2019 22:55:55 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXCPT-0007w2-Qb for pgsql-docs@lists.postgresql.org; Tue, 19 Nov 2019 22:55:54 +0000 Received: by mail-wr1-x443.google.com with SMTP id s5so25906179wrw.2 for ; Tue, 19 Nov 2019 14:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=u4hNPVyIhgykB3I3udic/S3qa2ZKBuPLFc9ScMe6TSw=; b=m6LS1pI0n6s/bBKyCMjZHjlsZSnkVzj9otdNBR8GfRz6uG4bBUgh0Z7gRimjXrDqnz F4qMrUuPR8MjmCybXaDKzy61qjC07xr4VfGdm31mvOmuLNMuX3DVueixPxCfPYuo03AY cUpsdrb4bv/AETBCGGWvx0rlhUkDt9v1sxfmmq4kzM2oBlxrjlYYyVaRyA+pyzS7C4Qs t+8AFtQL4QmgW/Qhy+45U3h3Iiu9gkE8oNHixpycg4npxeA5sY+0y8yc/r+i11/Y8v/Y HXcX/x8Zfg9Dh74vwjy6bULdPsvvX4bIcr32gHSwNEKoIFZGaLawj3ot5zT32bbklqKF G9Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=u4hNPVyIhgykB3I3udic/S3qa2ZKBuPLFc9ScMe6TSw=; b=BNE5LnOfiE+xke85lf4Y/0Dn+QMp/4NkQsoMWGnI7wa/yVpV0l/0a6pw4Nbg5g9D1r qmSIIu5/pmszI0V2Xnewg511XF+qRsi9M967kiD0vmlofDvIP7oQTNo/D6ov0fxrh/sT gVzOON4YJLz1szePeIXKI5Pyre2Jak4TVOIGD/avxOuRWSIRqjGbHquQhlX1I4eGUGn9 g2qXp6YQDCjbJEjRsdkpOzTfGoXuULUjx8B9fJSMS8AWiZHkNBeHJKJAJYq7eequgeYM WVaL5knQIrRoPllgGwenhdUNBHlF/YeCrNd4ZjXdvYi83KGPaerYrFWHm7yl6ndiefJb 0d3A== X-Gm-Message-State: APjAAAVDdr7MBkEk+jL0iegu36jnMJIqLteZIMw5jXYYs8IzUIWhbG6w WAn+WDickm1XX/eTSGv1Sp7WXQ== X-Google-Smtp-Source: APXvYqx3RjDK1UKXsxhS3APeUDmJgRPd+SlQMENLxJv1VjpebzvmDoIBrfm3Uf7v0F3n07uFv6GlNg== X-Received: by 2002:a5d:4142:: with SMTP id c2mr13254024wrq.60.1574204145682; Tue, 19 Nov 2019 14:55:45 -0800 (PST) Received: from localhost.localdomain (217-149-175-103.nat.highway.telekom.at. [217.149.175.103]) by smtp.gmail.com with ESMTPSA id t187sm4757386wma.16.2019.11.19.14.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 14:55:45 -0800 (PST) Message-ID: <41b4852ea43e59969cfefaf37c4578a23000075b.camel@cybertec.at> Subject: Re: Difference between Bulk Load (Multiple inserts or single inserts) and COPY From: Laurenz Albe To: mayank.l.patel90@gmail.com, pgsql-docs@lists.postgresql.org Date: Tue, 19 Nov 2019 23:55:44 +0100 In-Reply-To: <157418972366.28426.16885409770050714771@wrigleys.postgresql.org> References: <157418972366.28426.16885409770050714771@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com