From: Shantanu Shekhar <shekharshan@yahoo.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Stats for indexes on expressions
Date: Fri, 25 Dec 2020 05:32:16 +0000 (UTC)
Message-ID: <1258055935.2714481.1608874336314@mail.yahoo.com> (raw)
References: <1258055935.2714481.1608874336314.ref@mail.yahoo.com>
Hello,
I am trying to understand how the cost for a query involving indexes on expressions is calculated. How is the statistics on the expression maintained? For example Postgres documentation on 'Indexes on Expressions' mentions the following example:
CREATE INDEX people_names ON people ((first_name || ' ' || last_name));SELECT * FROM people WHERE (first_name || ' ' || last_name) = 'John Smith';
The index is created on an expression involving first name and last name. My confusion is basically around:
(1) When using this index how will the query planner get the stats on this expression? (2) Whenever an index on an expression is defined like this, should we rebuild the stats?
Thanks,
Shantanu
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: shekharshan@yahoo.com
Subject: Re: Stats for indexes on expressions
In-Reply-To: <1258055935.2714481.1608874336314@mail.yahoo.com>
References: <1258055935.2714481.1608874336314.ref@mail.yahoo.com> <1258055935.2714481.1608874336314@mail.yahoo.com>
* 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