I have a question regarding compatibility between versions of QGIS and PostgreSQL including PostGIS. Our IT security is switching to PostgreSQL version 13 (probably minor version 13.7) with PostGIS 3.1.4 soon. We are partly using QGIS version 3.4.5, mostly QGIS 3.10.4 as well as 3.22.10. Could there be any problems after the switch? Are there any analyses about this?
As discussed in an older question, QGIS supports connections to PostgreSQL/PostGIS through the use of the GDAL/OGR library. The version compatibility of the OGR vector drivers then determine the level of support for connections to PostgreSQL/PostGIS databases.
There is no clear statement of version compatibility for the libpq library that I could find in its documentation, but an old discussion thread about this (one copy here) states that
If your binary is just a client application that uses libpq to speak to the server, you can use any (supported) version of libpq with any (supported) server version.
I believe that statement would apply to QGIS built using GDAL/OGR. This discussion explicitly refers to PostgreSQL's versioning policy which states that PostgreSQL major versions are supported for 5 years after initial release.
project strives to support each minor version of PostGIS for 2-4 years after initial release and at the very least until the lowest PostgreSQL version supported by the PostGIS minor version is EOL'd.
For the particular versions mentioned by the OP, PostgreSQL versions 11 through 15 are currently supported (so use of PG 13.x should be fine and is supported until Nov. 2025) and PostGIS 3.1.4 supports PostgreSQL versions 11 through 14 (see matrix). Beyond that, check the version of GDAL you are using. The documentation for PostGIS says some newer features may be disabled if older dependencies (GDAL, Geos, Proj) are in use.