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 1n03Qj-0002Hr-3k for pgsql-general@arkaria.postgresql.org; Wed, 22 Dec 2021 15:21:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n03Qi-0007dY-0g for pgsql-general@arkaria.postgresql.org; Wed, 22 Dec 2021 15:21:24 +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 1n03Qh-0007dP-IU for pgsql-general@lists.postgresql.org; Wed, 22 Dec 2021 15:21:23 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n03Qe-0000Tr-Nv for pgsql-general@lists.postgresql.org; Wed, 22 Dec 2021 15:21:22 +0000 Received: by mail-wr1-x42d.google.com with SMTP id d9so5712497wrb.0 for ; Wed, 22 Dec 2021 07:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=NpIlMSaGH/z5nuvSF6tLWS9ksz7ANCQDaOyTq1qkMeA=; b=ApAmSi+WmAjaFBwvFyEzxr+xXBjgW965BCzHvfnF/MXQ3cJ9DqGtNLTKsPqDljo4ab 3cXnSx9P0BeeRZZ/zMLtp9DhuFm7z8a4bzYOveVKSih5iV2hpkDxNTeRqtI7RQs3kNVA y5s6l+ym6AG8YzMQKExx5rk9Ww2/GS5G9B/izyp7kOHOD+4srtSsODrJx8qv1GxERUY1 xqAreQ/m7x8jGVcjb4vguK1aG1ykAbhuQaDCzHFpW+6os077fb7rMVJ1wM422Dgkytom isod9rEnd0bOQk0Dovj8sEwusg+JWN3d3Yt0sPJv6EsZjQkMpaQb7IahJOOJfy5/YY8/ EFSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=NpIlMSaGH/z5nuvSF6tLWS9ksz7ANCQDaOyTq1qkMeA=; b=t+nvqZfNY2zALx6txCV4qqCcMEPxcRhGMBFLivFD0iX877onrIB+P7+mc2caGdcGaP mgOEc/wKvL1rjLm44d90reI9BfSlUZCuk0AubOnRWuuTYAdndasvxl1phkl94oKE6Hrr QX+EPM3W7U2UtKqqV8Iwj+sshpnrwr0MZhnbir6HXhi18EfWXS0eFe3S7DeMxVFxQYFy ElyEHYtzrW/wmbqKpS4i0APJX/Y2ath/XKLjzk5cJv1qNWbHVixnONDw3C9TjiuP689Q 0L2I5OpcyWBgxuNZgkf0jxTKYmf3wFceMx5PIiHaSGItboggdY+vq7ZbpzHo9P3UzIzS pG+w== X-Gm-Message-State: AOAM532mJ/uGLHGoBHr/vIyEBPFm5lq26/sRIOMXP/27qoenu7HTJc1t QoZIRhQkXX7szp8PtXtORSpGBNdc36n9Xw== X-Google-Smtp-Source: ABdhPJwgQuzdRpEvV0rfOzJ+szc4t7Cx/3p5QMuwyWs1fUJkgtL1Zp6qJdLBpSy7vYlYnQEpoSq3xg== X-Received: by 2002:a5d:4c48:: with SMTP id n8mr2408213wrt.25.1640186478149; Wed, 22 Dec 2021 07:21:18 -0800 (PST) Received: from localhost.localdomain (dynamic-ecbllfhf844bsxhrj-pd01.res.v6.highway.a1.net. [2001:871:5e:6b39:4518:25:34f3:c02f]) by smtp.gmail.com with ESMTPSA id p1sm2200533wrr.75.2021.12.22.07.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 07:21:17 -0800 (PST) Message-ID: <2efe68679dcc6c15bc956a6063b79e1e4018c006.camel@cybertec.at> Subject: Re: surprisingly slow creation of gist index used in exclude constraint From: Laurenz Albe To: Chris Withers , pgsql-general@lists.postgresql.org Date: Wed, 22 Dec 2021 16:21:16 +0100 In-Reply-To: <967c5f24-a8ad-11fa-be3a-d2e10747e179@withers.org> References: <789b3464-9bfc-2157-f4f4-71eb1da1050d@withers.org> <967c5f24-a8ad-11fa-be3a-d2e10747e179@withers.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-2.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2021-12-22 at 09:58 +0000, Chris Withers wrote: > A year and a half later, now that version 14 is the latest available, > I wonder if anything has changed with respect to gist index creation? > Probably also worth asking: are there now different index types this > application should be using? > > > I'm upgrading a database from 9.4 to 11.5 by dumping from the old > > cluster and loading into the new cluster. > > The database is tiny: around 2.3G, but importing this table is proving problematic: > > > > Column | Type | Modifiers > > ----------------+-------------------+---------------------------------------------------------- > >  period | tsrange | not null > >  col1 | character varying | not null > >  col2 | character varying | not null > >  col3 | integer | not null > >  col4 | character varying | not null default ''::character varying > >  id | integer | not null default nextval('mkt_profile_id_seq'::regclass) > >  deleted | boolean | not null default false > >  managed | boolean | not null default false > >  col5 | character varying | > > Indexes: > >     "mkt_profile_pkey" PRIMARY KEY, btree (id) > >     "mkt_profile_period_col1_col4_col2_chan_excl" EXCLUDE USING gist (period WITH &&, col1 WITH =, col4 WITH =, col2 WITH =, col3 WITH =) > > Check constraints: > >     "mkt_profile_period_check" CHECK (period <> 'empty'::tsrange) > > Foreign-key constraints: > >     "mkt_profile_col1_fkey" FOREIGN KEY (col1) REFERENCES host(name) > > > > 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. You could use "pg_upgrade" for upgrading, that will be much faster. Creating GiST indexes is still slow. You could test if any of the improvements since v11 have made your case faster. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com