pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Koen De Groote <kdg.dev@gmail.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Clarification on Expression indexes
Date: Tue, 16 Jun 2020 18:20:59 -0400
Message-ID: <1403342.1592346059@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGbX52GGzhBk+QtR8MeC_-rA=1ots=oCCAxQPouO84rQjDhfUA@mail.gmail.com>
References: <CAGbX52GGzhBk+QtR8MeC_-rA=1ots=oCCAxQPouO84rQjDhfUA@mail.gmail.com>

Koen De Groote <kdg.dev@gmail.com> 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





view thread (2+ messages)

Message-ID: <1403342.1592346059@sss.pgh.pa.us>
Permalink:  ../1403342.1592346059@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1403342.1592346059@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kdg.dev@gmail.com
  Subject: Re: Clarification on Expression indexes
  In-Reply-To: <1403342.1592346059@sss.pgh.pa.us>
  References: <CAGbX52GGzhBk+QtR8MeC_-rA=1ots=oCCAxQPouO84rQjDhfUA@mail.gmail.com> <1403342.1592346059@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox