On Wed, Feb 28, 2024 at 2:11 PM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
Dominique Devienne <ddevienne@xxxxxxxxx> writes:
> Views can have foreign-keys?
Surely you'd put the FK on the underlying table.
> Generated view columns be indexed?
You want an index on a virtual column? Sure, just build an _expression_
index (on the underlying table) that matches it.
I agree with Laurenz that it's hard to see much use-case here
that's not sufficiently covered already.
Oracle and SQLite have them, so, by definition, *many* more than one person (you don't get a feature added to Oracle that easily...) has seen sufficient reasons for doing it instead of modifying the underlying table, or building an _expression_ index.
My guess as to why they do it is "clarity of design".