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 1mpxzr-0001db-Op for pgsql-general@arkaria.postgresql.org; Wed, 24 Nov 2021 19:31:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpxzq-0006I1-Nf for pgsql-general@arkaria.postgresql.org; Wed, 24 Nov 2021 19:31:58 +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 1mpxzq-0006Hm-DB for pgsql-general@lists.postgresql.org; Wed, 24 Nov 2021 19:31:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpxzn-0002T2-IH for pgsql-general@lists.postgresql.org; Wed, 24 Nov 2021 19:31:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1AOJVrr0185059; Wed, 24 Nov 2021 14:31:53 -0500 From: Tom Lane To: "Godfrin, Philippe E" cc: "pgsql-general@lists.postgresql.org" Subject: Re: Inserts and bad performance In-reply-to: References: Comments: In-reply-to "Godfrin, Philippe E" message dated "Wed, 24 Nov 2021 19:15:31 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <185057.1637782313.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Nov 2021 14:31:53 -0500 Message-ID: <185058.1637782313@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Godfrin, Philippe E" writes: > I am inserting a large number of rows, 5,10, 15 million. The python code= commits every 5000 inserts. The table has partitioned children. > At first, when there were a low number of rows inserted, the inserts wou= ld run at a good clip - 30 - 50K inserts per second. Now, after inserting = oh say 1.5 Billion rows, the insert rate has dropped to around 5000 insert= s per second. I dropped the unique index , rebuilt the other indexes and n= o change. The instance is 16 vcpu and 64GB ram. Can you drop the indexes and not rebuild them till after the bulk load is done? Once the indexes exceed available RAM, insert performance is going to fall off a cliff, except maybe for indexes that are receiving purely sequential inserts (so that only the right end of the index gets touched). Also see https://www.postgresql.org/docs/current/populate.html regards, tom lane