It seems as though you have a transaction open that is holding onto a
whole lot of old rows.

Advertising

I have seen this happen somewhat-invisibly when a JDBC connection
manager opens transactions for each connection, and then no processing
happens to use those connections for a long time. The open
transactions prevent vacuums from doing any good...

Can't the backend be made to delay the "real" start of transaction until
the first query gets executed ?

That seems counter intuitive doesn't it? Why write more code in the
server when the client is the thing that has the problem?