Postgres is now async by Default
Summary
PostgreSQL has updated its default I/O method to the worker method, making it asynchronous by default across all supported platforms, including Mac, Windows, and Linux. This change is reflected in the "IO method" global user configuration (GUC), which now defaults to "worker". While the worker method is universally available, users on Linux systems with kernel version 5.x or higher can optionally switch to IO_uring for asynchronous I/O. IO_uring operates using submission and ready queues with shared memory between user and kernel space. The text notes that shared memory between user and kernel space has historically presented security challenges, as direct access from user space to kernel space typically requires a mode switch. The shift to the worker method as default may have been implemented to address potential bugs.
Key takeaway
For DevOps Engineers or Database Administrators managing PostgreSQL deployments, understanding the new async-by-default worker method is crucial. Your systems will now leverage asynchronous I/O out-of-the-box, potentially improving performance and stability. If running on Linux kernel 5.x+, you can evaluate switching to IO_uring for potentially higher performance, but be mindful of its historical shared memory security considerations. This change simplifies async setup and requires reviewing existing I/O configurations.
Key insights
PostgreSQL now defaults to an asynchronous worker-based I/O method, enhancing performance and consistency across platforms.
Principles
- Asynchronous I/O is now PostgreSQL's default.
- Worker-based I/O ensures broad platform compatibility.
- Shared memory between user/kernel poses security risks.
Method
The IO_uring mechanism involves submitting jobs to a submission queue and retrieving results from a ready queue, utilizing shared memory for communication between user and kernel spaces.
In practice
- Check "IO method" GUC for default worker.
- Consider IO_uring on Linux kernel 5.x+.
- Be aware of shared memory security implications.
Topics
- PostgreSQL
- Asynchronous I/O
- IO_uring
- Kernel I/O
- Shared Memory Security
- Database Administration
Best for: CTO, VP of Engineering/Data, Data Engineer, Software Engineer, DevOps Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Hussein Nasser.