When using the above to run a matrix server, it can be confusing how to verify and check which version of Postgres you are running. Fortunately this is really easy to check.
sudo matrix-postgres-cli --version
And you should get the version of Postgres that is being used.
psql (PostgreSQL) 9.6