postgresqlshared-librariesrdbms

Difference between local, session and shared preload library in PostgreSQL and use of LOAD command


I was working with some extensions (auto explain to be specific) which requires addition in preload libraries, but got confused between these three terms which are - local_preload_library, session_preload_libraries and shared_preload_libraries. I also wonder that if we need to use LOAD command in shared_preload_libarary also or only adding the extension name in shared_preload_library is sufficient?

I tried reading the documentation https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-LOCAL-PRELOAD-LIBRARIESbut didn't understand much. Can someone clarify the difference with some example?


Solution

  • I've never used the ones other than shared_preload_libraries, but just by reading the docs I would distill it down to (taking shared_preload_libraries as the "reference" case), session_preload_libraries differs in that it can be changed without restarting the server, and local_preload_library differs in that you don't need to be a superuser to set it.

    In no case do you need to LOAD, since "preload" means it has already been loaded at the point where you might need to otherwise do LOAD.