logoalt Hacker News

pksunkarayesterday at 5:01 PM3 repliesview on HN

I think a stored generated column allows you to create an index on it directly. Isn't it better approach?


Replies

tczMUFlmoNkyesterday at 5:13 PM

The article explains why they want to avoid this option:

> Starting at version 14, PostgreSQL supports generated columns - these are columns that are automatically populated with an expression when we insert the row. Sounds exactly like what we need but there is a caveat - the result of the expression is materialized - this means additional storage, which is what we were trying to save in the first place!

show 1 reply
zenmacyesterday at 5:43 PM

>I think a stored generated column allows you to create an index on it directly. Isn't it better approach?

Is it also possible to create index (maybe partial index) on expressions?

show 1 reply
rpswyesterday at 5:11 PM

I assume it would increase the storage usage, which they say they are trying to avoid in that example.