Web UI performance / PostgreSQL

In my efforts to speed up the web user interface of my (2 years old) nextcloud installation I found my postgresql database may be an issue (no numbers, just a feeling). The logs of this database server showed me that for just visiting the Nextcloud Talk page of my instance, about 50 lines of logs are produced, mainly consisting of snippets like the following:

2023-01-04 09:49:08.288 UTC [273171] [unknown]@[unknown] LOG:  connection received: host=192.168.x.x port=32804
2023-01-04 09:49:08.291 UTC [273171] nextcloud@nextclouddb LOG:  connection authorized: user=nextcloud database=nextclouddb SSL enabled (protocol=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384, bits=256, compression=off)
2023-01-04 09:49:08.316 UTC [273171] nextcloud@nextclouddb LOG:  disconnection: session time: 0:00:00.028 user=nextcloud database=nextclouddb host=192.168.x.x port=32804

So my question for the nextcloud side is:

  1. Is this intentional? Seems like very short-lived connections to me, this may be an issue (?)
  2. Is there nextcloud configuration potential to reduce the amount of connection creations?
  3. If not, should one use connection poolers like PGbounce or similar? What are larger-scale installations or well-performing setups doing about this?

it’s hard to judge based on few lines of logs you shared…

often Postgres is considered to be more performant backend than MySQL/MariaDB

but definitely it depends!

I have little experience with Postgres - my installation runs on MariaDB (because it’s default) but I feel such verbose logging results from very debug log setting - I would not expect the DB engine to log connection/login/disconnect by default… debug logging might reduce performance with very low load already… please double check you are running recommended production settings…

1 Like

Thanks for your reply! I’ll definitely check how I can reduce this logging (and it may even impact performance in a minor way), but at least it showed me that indeed nextcloud is reconnecting to the database upon every single request, which doesn’t look ideal to me