Thread: v18 virtual columns
Hi. I've just read https://www.dbi-services.com/blog/postgresql-18-virtual-generated-columns/
and I'm wondering whether there will be a way to ALTER existing STORED generated columns, to be virtual? W/o rewriting the whole table that is.
Thanks, --DD
On Thu, Feb 20, 2025 at 8:07 AM Dominique Devienne <ddevienne@gmail.com> wrote:
Hi. I've just read https://www.dbi-services.com/blog/postgresql-18-virtual-generated-columns/and I'm wondering whether there will be a way to ALTER existing STORED generated columns, to be virtual? W/o rewriting the whole table that is.
What about dropping the existing stored column then adding the new virtual column?
You won't get any disk space saving for existing records, but it's not going to rewrite the table.
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
On Thu, Feb 20, 2025 at 3:31 PM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Thu, Feb 20, 2025 at 8:07 AM Dominique Devienne <ddevienne@gmail.com> wrote:Hi. I've just read https://www.dbi-services.com/blog/postgresql-18-virtual-generated-columns/and I'm wondering whether there will be a way to ALTER existing STORED generated columns, to be virtual? W/o rewriting the whole table that is.What about dropping the existing stored column then adding the new virtual column?You won't get any disk space saving for existing records, but it's not going to rewrite the table.
Didn't think of that, but yes, I think that would work.
They are GENERATED columns, so the values stored are derived data anyway, indeed.
I also didn't know DROP COLUMN was smart enough not rewriting the column, that's good.
Thanks, --DD
On 2/20/25 05:06, Dominique Devienne wrote: > Hi. I've just read > https://www.dbi-services.com/blog/postgresql-18-virtual-generated-columns/ <https://www.dbi-services.com/blog/postgresql-18-virtual-generated-columns/> > > and I'm wondering whether there will be a way to ALTER existing STORED > generated columns, to be virtual? W/o rewriting the whole table that is. Nothing that I see here: https://www.postgresql.org/docs/devel/sql-altertable.html > > Thanks, --DD -- Adrian Klaver adrian.klaver@aklaver.com