Stats for indexes on expressions

From: Shantanu Shekhar <shekharshan(at)yahoo(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Stats for indexes on expressions
Date: 2020-12-25 05:32:16
Message-ID: 1258055935.2714481.1608874336314@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-12-25 06:09:02 Re: Stats for indexes on expressions
Previous Message Kyotaro Horiguchi 2020-12-25 02:32:13 Re: Problem with ssl and psql in Postgresql 13