I’m trying to understand when to use a static background worker vs a dynamic one in PostgreSQL.
From what I know so far:
- Static workers are registered during postmaster startup
- Dynamic workers can be started at runtime by a backend
I am building an extension that may need a bgw in the future. I am confused whether the extension must be listed in shared_preload_libraries or not. Since bgw can be registered on extension load, is there still a need to preload it, The bgw can also be created at runtime anyway.
So I want to know:
What is the exact difference between static and dynamic bgw in behavior and lifecycle
What can static bgw do that dynamic bgw cannot
In which cases should an extension use static bgw and require shared_preload_libraries
Any guidance or examples for deciding between the two
Thanks in advance.