currval sequence memory storage?

Started by Chris M. Gambleover 23 years ago2 messagesgeneral
Jump to latest
#1Chris M. Gamble
chris.gamble@cpbinc.com

I am using jdbc against postgres 7.2.1. My tables are all designed with a
serial field as the prmiary key. When I perform inserts, I have found
through FAQ's that I can use currval to get the last value used for the
sequence that is unique to my process. My questions is, when does the memory
storage used for this currval get released and what triggers its release? If
it is never released, does that cause the process to consume excessive
memory after several inserts across multiple tables?

Thanks,

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chris M. Gamble (#1)
Re: currval sequence memory storage?

chris.gamble@CPBINC.com writes:

My questions is, when does the memory
storage used for this currval get released and what triggers its
release?

It's not released until your session exits.

If
it is never released, does that cause the process to consume excessive
memory after several inserts across multiple tables?

Since the storage involved is just a few bytes for each distinct
sequence object that you've nextval'd in the current session, I doubt
that you need to worry. Certainly doing multiple inserts into a single
table isn't going to bloat your memory consumption, because you're
touching only one sequence.

regards, tom lane