Skip to content

RootDBA

DBA expertise: PostgreSQL, SQL Server & MySQL

Menu
  • Home
  • blog
  • PostgreSql
  • MySql
  • Sql Server
  • About AHMED – Root DBA
Menu

Postgresql configuration files

Posted on September 1, 2025September 1, 2025 by AHMED

postgresql.conf

  • file contain parameter to help configure and manage performance of the database server 
  • when we run initd command to create cluster it create postgresql.conf file default
  • the file allow one parameter per the line format 
  • parameter that require restart are clearly marked on the file
    many parameter need a server restart to take affect 

the file is located in data directory of the cluster 

default is located in /etc/postgresql/13/main/ 
9c76ca30fdcd0406050242888f258667.png

check parameter of PostgreSQL inside pgSQL console

the parameter you saw in the file can also be viewed in the psql console itself
to check and verified whether they enabled or not , and what is the parameter set for it
for example in the file there parameter called max_connection , i can see the value of it inside psql console by using show max_connection

view parameter using pg_setting

pg_setting is table contain all the infromation about config setup of postgresql.conf
you can query it to get parameters set
for example the below query will show parameter that recently edited and pending restart to apply 

select name ,source,boot_val,pending_restart from pg_settings where name = 'max_connections';

to get the list of column in pg_setting we can use the below option , useful in case you want to build query for yourself 

\d pg_setting 

select name , setting , category , boot_val from pg_settings where sourcefile = '/etc/postgresql/13/main/postgresql.conf';

view history of changes using pg_file_setting

this table contain log of any changes done on postgresql.conf file
6adec0738a219d52377c5f488ecaa93d.png

postgresql.autoconf

this file have parameter that allow to modify the postgresql.conf parameter from cli rather then editing the file itself 

the editing of postgresql.conf is very critical and better to edit it from psql command line using alter command 
keeping in mind some parameter require restart to reflect in the postgresql

example 1 , edit of the parameter work mem

this parameter we will edit it form pgSQL cli 

to view the current value use the show command and the parameter
syntax

show [paramter in postgresql.conf]; show work_mem ;

to alter command we use alter system set
syntax :
alter system set [parameter] = '[new value ]'; alter system set work_mem='10MB';
059a8b1bf0f9402535516c94e722b12a.png

check if changes require restart from psql cli

as mentioned before some changes require restart , for instance work_mem dosnt require restart .
to check if the change require restart go to postgresql.conf file and in there you will file comment ‘restart required ‘

or from cli itself you can check it by using the below query .

select * from pg_file_settings;

a74ac64a7a009d94727bb00f4032c5b1.png
applying column is showing ‘t’ meaning the changes is applied
there is column called error if its empty means no restart required if there s enters in the column means restart is required .
290e8a60e01134a02e071dea9df50a6e.png

does change in parameter reflect on postgresql.conf file .

we have changed the parameter fo work_mem from 3 to 10 let’s check if its reflected on postgresql.cnf file
43544dcb954391647c8f787ccbf8eca3.png

the value hasn’t changed why ?
acuity the changes is not edited in postgresql.conf file , it will be available in postgresql.autoconf
if you checked it you will find the changes you did for work_mem
the file will be located in the data directory of the db-cluster
/var/lib/postgresql/13/main/
if you check the content of the file you will find the new value for work_mem

cf32357fb08ab088270f7854bb0c8e78.png
when postgresql services start it will load config from postgresql.conf

then it will load config in the postgresql.auto.conf 

postgresql will load the value in postgresql.auto.conf and avoid load the value in postgresql.conf 

reset all

if you want to reset all the changes you did in psql cli using alter system
command
you can use the below query 

alter system reset all ;

this means all values in postgresql.auto.onf will be removed
but keep in mind it will not reset values in postgresql.conf
only changes done using alter system command will be reset
071280a21836507cadcce0c0e5ce251a.png


  • in short postgresql.auto.conf is useful to edit config of PostgreSQL without touching the postgresql.conf file 

pg _ident.conf

the file is part of authenticating section file of PostgreSQL and will allow to map OS user with PostgreSQL user
this file allow to match the user in PostgreSQL database with username in OS level 

any changes to the file require a reload only 

the file is located in /etc/postgresql/13/main/

i have PostgreSQL user called ahmed , but the user is not there in OS so i will create it and map it to user called postres in PostgreSQL

in the file you will asked to give friendly name for map , then add the OS username in Identity , then postgresql_username add PostgreSQL username
after that you need to reload PostgreSQL
dae5c80cc015e03e2b7728f08700d3c1.png

pg_hba.conf

enables clients authentication between PostgreSQL server and the client application

HBA means host based authenticating .

0
Visited 12 times, 1 visit(s) today
Category: PostgreSql, Postgresql Dba Guide

Post navigation

← PostgreSQL Directory layout
PostgreSql table inheritance , table partion →
© 2025 RootDBA | Powered by Minimalist Blog WordPress Theme