Re: What's the best practice to compare the transaction with the checkpoint? - Mailing list pgsql-novice

From Jialun Zhang
Subject Re: What's the best practice to compare the transaction with the checkpoint?
Date
Msg-id CAMFL+JisTCugv5T8n=gQNFKcvWMMJwARz1sWwhv1nQ8=EKvQTQ@mail.gmail.com
Whole thread Raw
In response to Re: What's the best practice to compare the transaction with the checkpoint?  (Gerald Cheves <gcheves@verizon.net>)
Responses Re: What's the best practice to compare the transaction with the checkpoint?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Actually I am trying to add file support for TOAST. I mean store the toasted value in the file system and leave a file path in the toast pointer. Therefore, for garbage collection, we need to remove the file after confirming that a deleted tuple is older than the latest checkpoint.

Thanks,
JIalun Zhang    

Gerald Cheves <gcheves@verizon.net> 于2020年7月6日周一 上午10:58写道:
On 7/6/2020 10:09 AM, Jialun Zhang wrote:
Thanks! But what I actually mean is how to do this in the backend source code. I think I could find a way to do this SELECT in backend.

What would be the advantage in that method?


Thank you,
Jialun Zhang

Laurenz Albe <laurenz.albe@cybertec.at> 于2020年7月6日周一 上午4:09写道:
On Sat, 2020-07-04 at 12:19 -0400, Jialun Zhang wrote:
> I am trying to add code to determine whether the transaction is checkpointed or not.
> So I think I need to compare the transaction ID with the checkpoint's and determine
> whether it is older or not. Could anyone tell me what's the best practice of doing
> this in Postgres? Is it done somewhere in the existing code?

You could use

   SELECT next_xid FROM pg_control_checkpoint();

to get information about the last checkpoint.

I refrain from asking what the point of the exercise is...

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com


-- 
siamo arrivati sani e salvi

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: What's the best practice to compare the transaction with the checkpoint?
Next
From: Tom Lane
Date:
Subject: Re: What's the best practice to compare the transaction with the checkpoint?