Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRbDp-0000UZ-IO for pgsql-performance@arkaria.postgresql.org; Tue, 08 Mar 2022 14:53:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nRbDo-0004Yv-0K for pgsql-performance@arkaria.postgresql.org; Tue, 08 Mar 2022 14:53:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRbDn-0004Yl-Mg for pgsql-performance@lists.postgresql.org; Tue, 08 Mar 2022 14:53:55 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRbDl-0007IL-6c for pgsql-performance@lists.postgresql.org; Tue, 08 Mar 2022 14:53:55 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1nRbDh-006bTg-Lf; Tue, 08 Mar 2022 09:53:49 -0500 Date: Tue, 8 Mar 2022 09:53:49 -0500 From: Bruce Momjian To: aditya desai Cc: Tom Lane , Pgsql Performance Subject: Re: Any way to speed up INSERT INTO Message-ID: References: <3967140.1646419359@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 8, 2022 at 06:36:17PM +0530, aditya desai wrote: > Hi Tom, > I added BEGIN and COMMIT as shown below around insert and executed it from > pgadmin for 100,000 rows. It ran in just 1 min. > > BEGIN; > INSERT INTO TABLE VALUES(....); > INSERT INTO TABLE VALUES(....); > . > , > COMMIT; > > However when I run above from psql by passing it to psql(As shown below) as a > file. It still takes a lot of time. Am I doing anything wrong? How can I run > this from pgadmin within a minute? > > psql -h host -U user -p Port -d database < INSERT_FILE.sql > > PSQL is still printing as below. > INSERT 0 1 > INSERT 0 1 Uh, they should be the same. You can turn on log_statement=all on the server and look at what queries are being issued in each case. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.