[QGIS-Developer] Max connection PostgreSQL limit

Francisco Puga fpuga at icarto.es
Thu Oct 6 02:13:03 PDT 2022


Hi,

I'm hitting the default (100) `max_connection` PostgreSQL limit with ~4
users using a QGIS project with ~25 layers/tables. I know that I can raise
the limit, but I'm trying to understand how QGIS handles database
connections.

I didn't find so much information about it:


   1.
   https://lists.osgeo.org/pipermail/qgis-developer/2008-March/003446.html.
   Old post against, something like, an internal connection pool in QGIS
   2. https://github.com/qgis/QGIS/issues/30373. Feature request to share a
   single connection between different layers
   3. https://stackoverflow.com/a/71557537/930271 an ¿explanation? of how
   connection works in QGIS. I copy&paste here because this post may be hide
   for some users:

for what I know every single layer creates at least one, possibly two,
> connections (one is read only the other one is read-write ), these two
> connections have the same lifetime of the layer, the read-write connection
> is created on-demand if a read-write operation is requested
> (editing/adding/deleting features).

Multiple layers using the same DB connection will not share these two
> connections.

In addition to the two connections above, temporary connections are created
> from a connection pool when the features are fetched from the layer(s),
> these connections are pooled (shared) and released when the fetching is
> finished, there is also a timeout to close them after 60 seconds idle.

It would be useful to check PG logs and see in which state these
> connections are, from my tests, the read-only connection is kept in
> ClientRead | idle.


So,

   - Can someone confirm the previous quote, explain how QGIS handles
   connections, or point me to relevant code or doc?
   - An invisible/unchecked layer consumes a connection?
   - Does make sense a feature request about this topic. Maybe
      - Reuse connection
      - a kind of internal pooling
      - a configurable user limit, so next database access will wait for
      other connections to close to start operations
      - ...

Many thanks.

-- 
Francisco Puga
iCarto | Innovación, Cooperación, Cartografía y Territorio S.L.
https://icarto.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221006/7cfc0bed/attachment.htm>


More information about the QGIS-Developer mailing list