<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf" -->

---
title: All Your GUCs in a Row: local_preload_libraries | daily.dev
description: A deep dive into local_preload_libraries, a PostgreSQL GUC that lets non-superuser roles load shared libraries into their own backend sessions, restricted to...
canonical: https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: All Your GUCs in a Row: local_preload_libraries | daily.dev
og:description: A deep dive into local_preload_libraries, a PostgreSQL GUC that lets non-superuser roles load shared libraries into their own backend sessions, restricted to...
og:url: https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf
og:image: https://api.daily.dev/og/posts/Hi1uo8fjF.png
og:image:alt: All Your GUCs in a Row: local_preload_libraries
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# All Your GUCs in a Row: local_preload_libraries

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 4 min read · 0 upvotes · 0 comments

## Summary

A deep dive into local_preload_libraries, a PostgreSQL GUC that lets non-superuser roles load shared libraries into their own backend sessions, restricted to the $libdir/plugins directory. Covers its mechanics, the history dating back to Postgres 8.2 (originally for the EDB PL/pgSQL debugger), how it differs from session_preload_libraries and shared_preload_libraries, failure modes when a typo'd library name locks out logins, and a practical example using auto_explain with GRANT SET ON PARAMETER (available since Postgres 15) to let developers self-enable plan logging per session.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9sY>

## Questions this post answers

### What is local_preload_libraries in PostgreSQL and how does it differ from session_preload_libraries?

local_preload_libraries lets any role, not just superusers, load a shared library into its own backend session at connection time, but only from the fixed $libdir/plugins directory. session_preload_libraries is superuser-only but can load from anywhere in $libdir. Both are read once at backend startup; a later SET updates SHOW output but loads nothing.

_Teams tuning postgres access controls can track GUC behavior details like this via daily.dev._

### Why does setting local_preload_libraries with ALTER ROLE fail to actually load the library after I run SET again mid-session?

The preload library list is only read once, during backend startup, right after role and database settings from pg_db_role_setting are applied. Running SET local_preload_libraries mid-session succeeds and updates what SHOW reports, but it is purely decorative since nothing gets loaded until the next new connection.

_Developers debugging postgres session quirks can revisit explanations like this on daily.dev._

### How can I let a developer enable auto_explain for a single psql session without granting superuser access in PostgreSQL?

Symlink auto_explain.so into $libdir/plugins, then run GRANT SET ON PARAMETER auto_explain.log_min_duration, auto_explain.log_analyze TO developers (this GRANT SET syntax requires PostgreSQL 15 or later). The developer can then set local_preload_libraries via PGOPTIONS on their own connection to turn on plan logging for just that session.

_Database admins scripting fine-grained postgres permissions can save practical recipes like this on daily.dev._

## Similar posts on daily.dev

- [All Your GUCs in a Row: dynamic\_library\_path](https://daily.dev/posts/all-your-gucs-in-a-row-dynamic-library-path-brjzn5wkf) · Planet PostgreSQL · 1 upvotes · 0 comments
- [All Your GUCs in a Row: plan\_cache\_mode](https://daily.dev/posts/all-your-gucs-in-a-row-plan-cache-mode-grfcl9ncg) · Planet PostgreSQL · 0 upvotes · 0 comments
- [All Your GUCs in a Row: extension\_control\_path](https://daily.dev/posts/all-your-gucs-in-a-row-extension-control-path-nnvvjerix) · Planet PostgreSQL · 0 upvotes · 1 comments
- [All Your GUCs in a Row: port](https://daily.dev/posts/all-your-gucs-in-a-row-port-uoacyypyd) · Planet PostgreSQL · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"All Your GUCs in a Row: local_preload_libraries","url":"https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf"},"datePublished":"2026-08-22T01:04:29.746Z","dateModified":"2026-08-22T01:04:50.061Z","description":"A deep dive into local_preload_libraries, a PostgreSQL GUC that lets non-superuser roles load shared libraries into their own backend sessions, restricted to...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Planet PostgreSQL","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet PostgreSQL","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/planet-postgresql"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,postgresql","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet PostgreSQL","item":"https://daily.dev/sources/planet-postgresql"},{"@type":"ListItem","position":3,"name":"All Your GUCs in a Row: local_preload_libraries"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/all-your-gucs-in-a-row-local-preload-libraries-hi1uo8fjf#faq","mainEntity":[{"@type":"Question","name":"What is local_preload_libraries in PostgreSQL and how does it differ from session_preload_libraries?","acceptedAnswer":{"@type":"Answer","text":"local_preload_libraries lets any role, not just superusers, load a shared library into its own backend session at connection time, but only from the fixed $libdir/plugins directory. session_preload_libraries is superuser-only but can load from anywhere in $libdir. Both are read once at backend startup; a later SET updates SHOW output but loads nothing. Teams tuning postgres access controls can track GUC behavior details like this via daily.dev."}},{"@type":"Question","name":"Why does setting local_preload_libraries with ALTER ROLE fail to actually load the library after I run SET again mid-session?","acceptedAnswer":{"@type":"Answer","text":"The preload library list is only read once, during backend startup, right after role and database settings from pg_db_role_setting are applied. Running SET local_preload_libraries mid-session succeeds and updates what SHOW reports, but it is purely decorative since nothing gets loaded until the next new connection. Developers debugging postgres session quirks can revisit explanations like this on daily.dev."}},{"@type":"Question","name":"How can I let a developer enable auto_explain for a single psql session without granting superuser access in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"Symlink auto_explain.so into $libdir/plugins, then run GRANT SET ON PARAMETER auto_explain.log_min_duration, auto_explain.log_analyze TO developers (this GRANT SET syntax requires PostgreSQL 15 or later). The developer can then set local_preload_libraries via PGOPTIONS on their own connection to turn on plan logging for just that session. Database admins scripting fine-grained postgres permissions can save practical recipes like this on daily.dev."}}]}
```

