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 1lCfPj-0000vw-WD for pgsql-general@arkaria.postgresql.org; Thu, 18 Feb 2021 09:16:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lCfPi-0004O2-UB for pgsql-general@arkaria.postgresql.org; Thu, 18 Feb 2021 09:15: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 1lCfPi-0004Nv-Kv for pgsql-general@lists.postgresql.org; Thu, 18 Feb 2021 09:15:58 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lCfPg-0007UX-4I for pgsql-general@postgresql.org; Thu, 18 Feb 2021 09:15:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qb9iwRfc/sxPj21Fmto2z+wM09z1IezEpkM0b9AezqU=; b=qTkYEz2P7LE6vx3851dyvcZ37N gcp9DB2yG3pIMjBTTE7msTXu7AEmnNzIMcG6MmYPicW7x/bAlh3RP4/gBsXLidX8ncUGDUpxMhzKt mYrRqrUrNj/j1e4Yo8ABX4dJ8HDpwABvf8JrrzwLzzvnVBA8JCuq5MDEfutz15mS/+ec=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1lCfPd-0001Kr-JU; Thu, 18 Feb 2021 10:15:53 +0100 Date: Thu, 18 Feb 2021 10:15:53 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Paul van der Linden Cc: pgsql-general Subject: Re: Slow index creation Message-ID: <20210218091553.GA25223@depesz.com> Reply-To: depesz@depesz.com References: <20210217184808.GA14032@depesz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Feb 17, 2021 at 08:40:17PM +0100, Paul van der Linden wrote: > The st_area calculation is done mostly once or sometimes twice for each geom, and I suspect that can't explain the factor 20 slower. > Creating an index with only one st_area calculation is also done rather quickly. In this case, make small test case, like 1000 rows, or something like this. run create index without where, and then remake the functions with profiling info, for example using this approach: https://www.depesz.com/2010/03/18/profiling-stored-proceduresfunctions/ and check for yourself what takes this time, and if it's something you can fix. Best regards, depesz