PostgreSQL#
Querona uses the Npgsql ADO.net driver for PostgreSQL connectivity. NpgSQL driver is bundled with Querona, and no additional installation is required.
Example connection strings#
For a complete list of connection string parameters see Npgsql Connection String Parameters.
Encrypted connection (SSL/TLS)#
By default PostgreSQL connections are unencrypted, but you can turn on SSL/TLS encryption if you wish.
Specify SSL Mode in the connection string, setting it to either Require (connection will fail if the server isn’t set up for encryption),
or Prefer (use encryption if possible but fallback to unencrypted otherwise).
Example connection string with SSL enabled. Notice the SSL Mode=Prefer at the end of connection string:
Host=[Servername];Username=[Username];Password=[Password];Database=postgres;Port=5432;SSL Mode=Prefer;
Note that by default, Npgsql will verify that your server’s certificate is valid.
If you’re using a self-signed certificate, this will fail.
You can instruct Npgsql to ignore this by specifying Trust Server Certificate=true in the connection string.
Example connection string with SSL enabled and self-signed server certificate.
Notice the SSL Mode=Prefer and Trust Server Certificate=true at the end of connection string:
Host=[Servername];Username=[Username];Password=[Password];Database=postgres;Port=5432;SSL Mode=Prefer; Trust Server Certificate=true;
Connection pooling#
Connection pooling for PostgreSQL connections is off by default. When pooling is enabled, Querona keeps one connection pool per distinct connection string: connections that share the same configuration (host, credentials, database, and pooling settings) draw from a single pool capped by the maximum pool size, while a connection using a different database (or any other differing setting) uses its own separate pool.
In addition to the minimum and maximum pool size, two further pooling settings can be configured: connection idle lifetime (how many seconds an idle connection above the minimum pool size is kept before being closed) and connection pruning interval (how many seconds elapse between each pruning sweep of the pool). Since Npgsql 9, the underlying driver’s default connection lifetime is 3600 seconds unless a different value is configured. Changed pooling settings apply to connections opened after the change; connections already open continue under the previous settings until they are closed.