Re: sequence cache is kept forever

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: sequence cache is kept forever
Date: 2021-11-19 17:50:48
Message-ID: 3087536.1637344248@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
> While working on a patch, I noticed that we never clean the cache of
> sequence values, i.e. seqhashtab in sequence.c. That is, once we create
> an entry for a sequence (by calling nextval), it will stay forever
> (until the backend terminates). Even if the sequence gets dropped, the
> entry stays behind.

It might be reasonable to drop entries when their sequence is dropped,
though I wonder how much that would move the needle for real-world
usages. Dropping an entry "just because" risks losing cached value
assignments, which might be unpleasant (e.g. due to faster advancement
of the sequence's counter, more WAL traffic, etc). With no actual
complaints from the field, I'm disinclined to do that.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marcos Pegoraro 2021-11-19 17:57:32 Re: update with no changes
Previous Message David G. Johnston 2021-11-19 17:37:52 Re: update with no changes