What Is a GUC Variable?

December 01, 2011

Thursday, December 1, 2011

You might have heard the term "GUC" before, especially on the Postgres email lists. It is documented as an acronym meaning "Grand Unified Configuration", but the section it references doesn't mention the term "GUC" at all. Pretty obscure, huh?

Our Grand Unified Configuration (GUC) system was created in 2000 as a way to control Postgres at various levels. You are probably most familiar with controlling Postgres via the postgresql.conf file or using the SQL SET command, but it is much more powerful than that.

In fact, people often get into the habit of changing variables at certain levels, and never realize that these variables can be set at more global and more local levels. Of course, some settings, like shared_buffers can only be set in postgresql.conf. (These entries are usually marked with the file comment "(change requires restart)".) But other settings, like work_mem and search_path, can be set at many levels. This email gives a very concise description:

 

The closest thing to global variables are GUC settings. These can be set globally in postgresql.conf, per user and/or per-database via ALTER ROLE/DATABASE ... [IN DATABASE ...], per session with SET, per function via CREATE FUNCTION ... SET and finally per subtransaction with SET LOCAL.

 

Of course, our documentation has an even more detailed explanation.

As I have said many times before, our GUC system seems limited at first, but once you realize that you can combine settings and set them at various levels, it becomes a powerful tool that can meet almost any need.

Share this

More Blogs

Explaining ABI Breakage in PostgreSQL 17.1

PostgreSQL comes out with a scheduled major release every year and scheduled minor releases for all supported versions every quarter. But in the November minor releases, two issues caused the...
December 06, 2024