Re: Postgresql long transaction support

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Midgley <science(at)misuse(dot)org>
Cc: Kirmo Uusitalo <kirmo(dot)uusitalo(at)gmail(dot)com>, Samed YILDIRIM <samed(at)reddoc(dot)net>, pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: Postgresql long transaction support
Date: 2022-12-14 21:13:32
Message-ID: 2873812.1671052412@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Steve Midgley <science(at)misuse(dot)org> writes:
> This seems pretty complex to address at any layer! But it would be a useful
> feature for some situations, for sure. It seems like the approach taken by
> Ruby/Rails and similar frameworks for "db migrations" might have some
> useful design patterns for you. Each transaction has a link to its future
> and past transaction. If the system wants to traverse from "migration 6 to
> migration 3" and the DB is currently at migration 6 (stored a version
> number in the db itself), it runs the exit function to downgrade to
> migration 5, then runs the logic for migration 5, then runs the downgrade
> to 4, etc.

> It can be slow, as implemented, but it allows you to attach logic to every
> step forward and backward in time that ensures you can handle even
> structure changes in the tables, etc (as well as changing lookup values in
> tables, etc).

> Might be worth considering as a design model?

If you end up building things that way, PG's "extensions" could be a
useful way to package it. What Steve is calling a "migration" corresponds
to an extension version, and you can provide scripts to go in either
direction between versions.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Carl Sopchak 2023-01-07 20:35:41 Order By weirdness?
Previous Message Steve Midgley 2022-12-14 19:59:44 Re: Postgresql long transaction support