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 1jZKVh-0001li-I9 for pgsql-general@arkaria.postgresql.org; Thu, 14 May 2020 20:31:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZKVf-0003uB-E2 for pgsql-general@arkaria.postgresql.org; Thu, 14 May 2020 20:31:15 +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 1jZKVf-0003tW-6R for pgsql-general@lists.postgresql.org; Thu, 14 May 2020 20:31:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZKVb-00034I-UR for pgsql-general@lists.postgresql.org; Thu, 14 May 2020 20:31:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 04EKVAgc001425; Thu, 14 May 2020 16:31:10 -0400 From: Tom Lane To: Chris Withers cc: pgsql-general@lists.postgresql.org Subject: Re: surprisingly slow creation of gist index used in exclude constraint In-reply-to: <789b3464-9bfc-2157-f4f4-71eb1da1050d@withers.org> References: <789b3464-9bfc-2157-f4f4-71eb1da1050d@withers.org> Comments: In-reply-to Chris Withers message dated "Thu, 14 May 2020 21:11:54 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1423.1589488270.1@sss.pgh.pa.us> Date: Thu, 14 May 2020 16:31:10 -0400 Message-ID: <1424.1589488270@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Chris Withers writes: > It has 4.1 million rows in it and while importing the data only > takes a couple of minutes, when I did a test load into the new > cluster, building the mkt_profile_period_col1_col4_col2_chan_excl > index for the exclude constraint took 15 hours. Don't recall for sure, but I think GIST index build is sensitive to the maintenance_work_mem setting; did you have that cranked up? > - failing that, what can I do to import and then create the index > in the background? CREATE INDEX CONCURRENTLY, perhaps. regards, tom lane