Postgresql – In postgresql.conf, does the order of the listed parameters matter

postgresqlpostgresql-12

I'm relatively new to the DBA field and I have read the official documentation/guides on this topic, but I apologize if my question seems weird.

I have deployed PostgreSQL 12 on my AWS instance and tried to install the pgaudit extension.
In the postgresql.conf configuration file you need to add shared_preload_libraries = 'pgaudit' and restart the PostgreSQL service to apply the change.

I added shared_preload_libraries = 'pgaudit' in the very end of the config file and restarted pg_ctl, which caused the service to crash. Postgresql started operating normally once I commented out the added line.

Later I found the shared_preload_libraries parameter in that config file, it was already there, located a few blocks above, but also commented out. Once I uncommented it and set its value to 'pgaudit', my postgresql service started working normally and I managed to create an extension.

My question is: does it really matter in what order you list the parameters? Why didn't it work when I added the line in the end of the file, but worked, when the line was somewhere in the middle?

Best Answer

If you have several times the same parameter in postgresql.conf, the last value will override the previous ones.

I normally advise keeping the postgresql.conf file as short as possible to prevent confusion. See here.

My guess is that you misspelled something on the line you added. To be sure, you can look at Postgres logfiles which should tell you exactly what was wrong. (see here how to find your Postgres logfile.)