Re: support create index on virtual generated column.

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: support create index on virtual generated column.
Date: 2026-01-08 06:16:49
Message-ID: CACJufxEygt-OkS9qSCshNu+fq4533AA0BCBtboW9Mi3xujp=Uw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 31, 2025 at 2:24 AM Corey Huinker <corey(dot)huinker(at)gmail(dot)com> wrote:
>
>>
>> Besides, this does nothing you haven't been able to do for
>> decades with expression indexes.
>
>
> What I'm hoping for with this feature is a smoother transition when people start introducing virtual columns. If there was already an index on that expression, and some queries start using the new virtual column (with the same expression), will that cause those queries to miss the index we already have? If it doesn't, then a customer can roll out the query changes at will and not need to do some cut-over from using the expression to using the virtual column.
>

hi.
I am not sure whether this concern has been addressed, as I am still somewhat
confused by the above paragraph.

As noted earlier, creating an index on a virtual generated column results in a
new index, and that index behaves the same as a regular expression index.

An updated and polished patch is attached. The regress tests are quite verbose
at the moment, since I make it covered all index types (btree, gist, spgist,
hash, gin, and brin).

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v7-0001-index-on-virtual-generated-column.patch text/x-patch 76.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Chen 2026-01-08 06:18:44 Re: Optimize SnapBuildPurgeOlderTxn to purge committed xids in-place
Previous Message Gilles Darold 2026-01-08 06:04:16 Re: Pasword expiration warning