Re: Improving the names generated for indexes on expressions

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-16T12:39:21Z
Lists: pgsql-hackers
On Tuesday, September 16, 2025, Robert Haas <robertmhaas@gmail.com> wrote:

> On Tue, Sep 16, 2025 at 12:56 AM David G. Johnston
> <david.g.johnston@gmail.com> wrote:
> > If there are no function names present, output “expr” in lieu of a
> function name.  Then just output any columns that are present.  No
> operators, no constants.
>
> In the previous discussion, the user's expression indexes were on
> these expressions:
>
> jsondata -> 'a' -> 'b'
> jsondata -> 'x' -> 'y'
>
> So "no operators, no constants" wouldn't really allow us to make any
> useful progress, inasmuch as it would throw away everything that
> matters.
>

Wouldn’t mind special-casing json/jsonb in the algorithm:
 tbl_col.const.const_idx

More generally, maybe map all the various common accessor operators to “.”
instead of using them directly and capture the constants when chained from
a column.

This forces the need for double-quoting but that doesn’t seem like
something we can really avoid.

Keeps the name short by collapsing the operator to a single symbol, and
removing single quotes from the constants.

David J.

Commits

  1. Improve the names generated for indexes on expressions.