PostgreSQL – Get Last Usage of Sequence

postgresqlsequence

I have a database that has both sequenced correlated to table unique ids and "standalone" but having values.

I need to know which ones are really used but I'm not the owner of every procedure running on the database.

Is there any way to know when a Postgres sequence was last used?

Best Answer

No, the time when a sequence is used is not recorded by PostgreSQL.

I would figure out the last_value of each sequence, wait for a week and do it again. Then you can easily see which sequences have advanced and how much.