I can quickly query the database name with SELECT current_database(); but I've been searching for way to also query the cluster name and version with no luck - hoping someone can suggest a solution.

  • cannot retract a question after I've found an answer: select name || '=' || setting from pg_settings where name in ('port','cluster_name');
    – Reinsbrain
    Commented Jul 9, 2019 at 10:10
  • 2
    You could always self-answer (if your solution is materially different to the answers already posted) and accept your own answer if you feel it best suits your question. 😉 Commented Jul 9, 2019 at 10:14

2 Answers 2


That would be

SELECT current_setting('cluster_name'), current_setting('server_version');

You can get all parameters that way. For automated processing, server_version_num is often better.

  • I mistakenly presumed you can only find settings that are defined in postgresql.conf and now know otherwise - I'm a little more powerful postgresql dev now thanks to @Laurenz Albe
    – Reinsbrain
    Commented Jul 9, 2019 at 10:26

You can also query the pg_settings view

SELECT name, setting FROM pg_settings WHERE name in ('cluster_name','server_version','port');

@Laurenz Albe suggests using current_setting() which makes it easier to select results in a single row

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.