PostgreSQL 18 is out, bringing several notable improvements to performance (asynchronous I/O subsystem) and developer ergonomics.
For Rails developers, the upstream community moved quickly to ensure compatibility in ActiveRecord. Here are the highlights most relevant to Rails applications.
Rails Support in ActiveRecord
Rails merged two key pull requests to support PostgreSQL 18 out of the box:
- rails/rails#55784: Updates the PostgreSQL adapter version detection to recognize PG18 correctly and prevent version mismatches.
- rails/rails#55142: Adds recognition for new PostgreSQL 18 internal OID (Object Identifier) types so ActiveRecord handles new column types smoothly.
Native uuidv7() Support
The most exciting addition for Rails apps is PostgreSQL 18’s native uuidv7() function.
Traditionally, using UUIDs in Rails required either:
- Random UUIDv4 (which fragments B-tree indexes due to lack of sequential ordering), or
- Third-party extensions like
pgcryptoor application-level UUIDv7 generation gems.
UUIDv7 embeds a millisecond timestamp at the beginning of the identifier, making IDs monotonically sortable while retaining uniqueness. With PostgreSQL 18 supporting uuidv7() natively in core:
- Primary key index inserts remain clustered and sequential (avoiding page splits in B-trees).
- You no longer need external database extensions or application callbacks to generate time-ordered UUIDs.
-- In PostgreSQL 18
SELECT uuidv7();
Other Notable PG18 Changes
- Asynchronous I/O (AIO): Parallel I/O requests for sequential and bitmap heap scans, noticeably speeding up large analytical queries and vacuuming.
- Query Optimizations: Skip scans on multi-column B-tree indexes and improved parallel index builds for GIN indexes.
- Faster Upgrades: Optimizer statistics are preserved across
pg_upgrade, reducing warm-up latency on major version bumps.
Summary
ActiveRecord already handles PG18 cleanly thanks to recent patches. If your Rails application uses or plans to adopt UUID primary keys, the native uuidv7() support alone makes testing PostgreSQL 18 well worth the upgrade path.