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 1jlJx8-0007Ar-22 for pgsql-general@arkaria.postgresql.org; Tue, 16 Jun 2020 22:21:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlJx6-00060t-Ju for pgsql-general@arkaria.postgresql.org; Tue, 16 Jun 2020 22:21:08 +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 1jlJx6-00060m-Bt for pgsql-general@lists.postgresql.org; Tue, 16 Jun 2020 22:21:08 +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 1jlJx1-0002jl-2K for pgsql-general@lists.postgresql.org; Tue, 16 Jun 2020 22:21:07 +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 05GMKxms1403343; Tue, 16 Jun 2020 18:21:00 -0400 From: Tom Lane To: Koen De Groote cc: PostgreSQL General Subject: Re: Clarification on Expression indexes In-reply-to: References: Comments: In-reply-to Koen De Groote message dated "Tue, 16 Jun 2020 23:53:13 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1403341.1592346059.1@sss.pgh.pa.us> Date: Tue, 16 Jun 2020 18:20:59 -0400 Message-ID: <1403342.1592346059@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Koen De Groote writes: >> Index expressions are relatively expensive to maintain, because the derived >> expression(s) must be computed for each row upon insertion and whenever it >> is updated > I'd like to get an idea on "relatively expensive". It's basically whatever the cost of evaluating that expression is, plus the normal costs of index insertion. If the expression is something built-in like sin(x), probably the evaluation cost is negligible ... but with a user-defined function in SQL or some PL, maybe not so much. In any case, the real question is "how many expression evaluations am I going to save over the life of the row, versus how many I pay up-front?" You didn't address how many queries would benefit from having the index, so the question is unanswerable with just these facts. regards, tom lane