PostgreSQL 18 and Rails: Compatibility and Native UUIDv7

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 pgcrypto or 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.

Related
Rails · Kamal My First Rails Deployment Journey with Kamal

Notes on deploying a Rails app with Kamal for the first time: proxy conflicts with Caddy, Cloudflare forward_headers, and debugging Docker volume mounting errors.

Oct 22, 2025
AI · Claude Code Building Lexio with Two Claudes: A Workflow That Actually Works

How I use Claude Projects for architecture decisions and Claude Code for implementation—keeping thinking and coding deliberately separate, with Lexio as a real-world example.

Mar 13, 2026
Rails · Basecamp Inside Fizzy's Authentication Architecture: A Three-Tier Approach to Multi-Tenant SaaS

How 37signals' Fizzy structures multi-tenant authentication with an Identity → User → Account model, enabling users to belong to multiple organizations cleanly.

Jan 09, 2026
All posts