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 1jZbs6-0001RF-KV for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 15:03:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZbs5-0006bB-Eo for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 15:03:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZbs4-0006Yi-H0 for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 15:03:33 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZbrx-0005zS-Oh for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 15:03:31 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 82ABB5C00DA; Fri, 15 May 2020 11:03:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 15 May 2020 11:03:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=withers.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=umZlODEbRQikTWgfrRMZhKYF0WThyyARg+jLTqJVI3M=; b=juCgZnEQXfmZ /lhyyxo+Q/s60KUOYwLbHTZg5D8dZMmDJPmY6moMZPqX9r6NAO8qvoOeLQYSYLit kMtwPkhbxBSGTuN4M737kDCrR2CYb/Hpz2fI1F05pv4ANJcDGAg6u0kj8pgy63+V lgLczqAMqc29EtadFGQV56VlwBJwsVI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=umZlODEbRQikTWgfrRMZhKYF0WThyyARg+jLTqJVI 3M=; b=SXefyGR/rwwH+FqJK4OQiEXQeHa10/CCKeSNkCDfCf0rsihoFpd1BU88T bRD0RLnuSvd9izBiDU1nl4xL5TijEJSV1nYugI3FQeh15lDbth4bRdPt6W7JNulL ewUvcir77r4AU7zwtxZH0PJlgoLgSQUCVFnvYyQUaulqwxwqb34Jvv6iK0y27lNz c1pE1Y9FawHzGbktFmLcmT8whhAGY8FQNKd7LxGWKVgHc59mYcspjgM/E7NZDBTP NhCA4GW9AVDd1agvE7YpmbrIVDDdu6JleQS/WnSS+2qRzYHgNuE+EHpdVodh/0sP y7t2e4gQJpcNpwb2mbAuhbXeG79lA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrleekgdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthejre dttdefjeenucfhrhhomhepvehhrhhishcuhghithhhvghrshcuoegthhhrihhsseifihht hhgvrhhsrdhorhhgqeenucggtffrrghtthgvrhhnpefgieeuheevtdfhgfekudehkeevge eiveekudefheevkefhhfdvlefgieetueehudenucfkphepkedvrddvuddrvddtkedrudek vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegthh hrihhsseifihhthhgvrhhsrdhorhhg X-ME-Proxy: Received: from [192.168.1.34] (cpc95902-rdng25-2-0-cust181.15-3.cable.virginm.net [82.21.208.182]) by mail.messagingengine.com (Postfix) with ESMTPA id 73E22328005A; Fri, 15 May 2020 11:03:22 -0400 (EDT) Subject: Re: surprisingly slow creation of gist index used in exclude constraint To: Tom Lane Cc: pgsql-general@lists.postgresql.org References: <789b3464-9bfc-2157-f4f4-71eb1da1050d@withers.org> <1424.1589488270@sss.pgh.pa.us> From: Chris Withers Message-ID: Date: Fri, 15 May 2020 16:03:19 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1424.1589488270@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 14/05/2020 21:31, Tom Lane wrote: > 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? postgres=# show maintenance_work_mem; maintenance_work_mem ---------------------- 2GB (1 row) Would it be worth turning that up more? The server has ~130GB memory. >> - failing that, what can I do to import and then create the index >> in the background? > > CREATE INDEX CONCURRENTLY, perhaps. How would I bring this into play with respect to the dump and load cycle? Is there an option to pg_dump or something else I should use or is this a case of awk'ing the create index in the dump? Chris