Idle database connections

Nextcloud version: 21.0.5
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18.0-0ubuntu1.2
PHP version (eg, 7.4): php 8.0.11

The issue we’re facing is that Nextcloud keeps database connections open in idle state and eventually we’re running out of available connections.
All idle connections are with the same query:

UPDATE 
      "oc_preferences" 
SET 
      "configvalue" = CAST((CAST("configvalue" AS INT) + 1) AS TEXT) 
WHERE 
      ("userid" = $1) 
AND 
      ("configkey" = $2) 
AND 
     ("appid" = $3)

Eventually, it closes them, perhaps a timeout, but it happens during the day to run out of available connections, due to the retain idle ones.

It started happening since we upgraded to version 21.0.5, before we were on 21.0.1 and we didn’t have that issue.

I have the log files from nginx and nextcloud but there’s nothing pointing to to what is keeping the connections and why.