PostgreSQL 18 and Rails: New Features and UUIDv7 Support

PostgreSQL 18 and Rails: New Features and UUIDv7 Support

PostgreSQL 18 has just been released, continuing the tradition of steady, meaningful improvements to one of the most popular open-source databases. Alongside this, the Rails team has already merged patches to ensure smooth support for PG18 in ActiveRecord.

In this post, I’ll cover some of the key highlights of PostgreSQL 18, walk through the recent Rails pull requests that bring compatibility, and discuss what this means for developers looking to upgrade their stack.

Key Highlights of PostgreSQL 18

PostgreSQL 18 introduces a wide range of improvements across performance, developer experience, and security. Here are some of the most notable changes:

  • Asynchronous I/O Subsystem (AIO): PostgreSQL can now issue parallel I/O requests for sequential scans, bitmap heap scans, and vacuum operations, resulting in up to 3x performance improvements in some workloads.
  • Faster Upgrades: Query planning statistics are preserved across major upgrades, reducing warm-up time. pg_upgrade has been improved with faster checks, parallel validation, and a new --swap mode.
  • Query and Index Optimizations: Support for skip scans on multicolumn b-trees, improved OR condition handling, and enhancements to hash joins and incremental sorts. GIN indexes can now be built in parallel.
  • Developer Experience: New virtual generated columns, the ability to reference OLD/NEW values simultaneously in RETURNING, a built-in uuidv7() generator, and support for temporal constraints.
  • Text Processing: Introduction of PG_UNICODE_FAST collation, better case-insensitive comparisons, and default full-text search now using cluster collation.
  • Authentication & Security: OAuth 2.0 authentication support, new TLS 1.3 configuration options, and deprecation of md5 authentication.
  • Replication & High Availability: Logical replication now supports parallel streaming of transactions, with automatic cleanup of idle replication slots.
  • Monitoring & Maintenance: Improved vacuum strategies and more detailed EXPLAIN/ANALYZE output, including metrics for buffers, index lookups, CPU, and WAL usage.

Rails Support for PostgreSQL 18

The Rails community is usually quick to adapt to new PostgreSQL releases, and PG18 is no exception. Two notable pull requests were merged recently to bring compatibility:

  • rails/rails#55784 — Update PostgreSQL Adapter to Recognize Version 18This ensures Rails correctly detects PostgreSQL 18 when establishing connections. Without this patch, Rails might misreport the database version, leading to subtle compatibility issues.
  • rails/rails#55142 — Handle New OID Types Introduced in PostgreSQL 18PostgreSQL assigns unique OIDs (object identifiers) to built-in types. With PG18 introducing new data types, ActiveRecord needed updates to recognize and map these correctly. This prevents errors when working with PG18-specific columns.

Together, these patches mean that Rails developers can upgrade to PG18 with confidence, knowing that ActiveRecord is prepared to work seamlessly.

Conclusion

PostgreSQL 18 brings meaningful improvements in performance, indexing, and developer experience. Thanks to quick community work, Rails already supports PG18 through targeted patches.

If you’re running a Rails application, now is the time to start testing PG18 in staging environments and explore how the new features can benefit your workload. With ActiveRecord ready to handle the changes, upgrading should be a smooth process.

One feature I personally find most exciting is the new `uuidv7()` function. For Rails apps that already prefer UUIDs as primary keys, this change means a cleaner, faster, and more standard approach to ID generation.