PostgresAI (@postgres_ai) header
PostgresAI (@postgres_ai) profile picture

We build Self-Driving Postgres and help fast-growing startups scale their databases, workloads, and related operations

remote
Joined July 2020
Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)Photo by PostgresAI (@postgres_ai)
Postgres feeling unwell? Paste one prompt into your AI agent. It sets up @postgres_ai monitoring πŸ“ŠπŸ“ˆ then finds the root cause. Here: long open transactions holding locks. 26 seconds. Works with Claude Code, Cursor, Codex, or any agent that runs commands. Any Postgres: self-managed, Supabase, RDS (+ more coming soon) link πŸ‘‡
16
3
31
2,092
Random UUID primary keys look fine on day one: id uuid default gen_random_uuid() primary key At scale, INSERTs run much slower. Postgres 18.6, 16 clients, single-row inserts, same server: β†’ small table: UUIDv4 at 0.95–1.10x of UUIDv7 β†’ 100M rows: 0.62–0.69x of an ordered key β†’ WAL per row: 1.5–1.9x β†’ index size: +33% vs UUIDv7 Each UUIDv4 insert lands on a random leaf, so the whole index is hot. Past memory, almost every insert reads a page and evicts another one. Postgres 18 has uuidv7(). For an existing table, one statement under a short lock_timeout: alter table t alter column id set default uuidv7(); 7 runs, 14 hypotheses written down before the first row. Link below πŸ‘‡
9
10
1
52
3,939
PostgresAI retweeted
How we tested: ~2.1B UUID rows across 7 runs, driven by AI agents in DBLab Forge, PostgresAI's experiment platform. ~1.5B tokens (mostly cached context; ~10.5M generated). Every number, chart and config πŸ“Š console.postgres.ai/shared/b…
1
1
577
PostgresAI retweeted
What happens when a random-key index outgrows shared_buffers? And what does UUIDv7 reveal about your data? Kirk Wolak and Nik dig into both in episode 194 πŸŽ™οΈ ▢️ youtube.com/watch?v=gf8e3JkQ… 🎧 postgres.fm/episodes/uuidv4-…
1
2
9
1,469
PostgresAI retweeted
🚨 UUIDv4 or UUIDv7 for your Postgres primary key? We inserted 2 billion UUIDs to settle it. 100M rows. Postgres 18. 1 GiB shared_buffers. ⚑ int8: 23.5k inserts/s ⚑ UUIDv7: 21.7k inserts/s 🐌 UUIDv4: 13.9k inserts/s UUIDv4 starts slowing at ~26M rows. Why? πŸ‘‡
7
18
138
15,571
Why does this keep happening? pg_restore doesn't do it for you. Autovacuum does it eventually: in tests from my blog post, after 6 s to 6+ minutes. And (!) it never analyzes partitioned parents. Yes, Postgres could do a better job. But also most existing guides stop at "pg_restore finished". I checked 28 of them, incl. Postgres docs, AWS, Google Cloud, Azure, Supabase, Neon: β†’ only 8/28 say to run ANALYZE β†’ only 3/28 say to run VACUUM β†’ and just 1 explains what visibility maps are Only one tells the whole story. Full research, all 28 pages: github.com/NikolayS/postgres… So teams step on the same rake πŸ€• βœ… Check your runbooks, scripts and AI agent skills. Before traffic: vacuumdb --analyze --jobs 4 # adjust plus ANALYZE each partitioned parent Follow me for more Postgres tips the docs leave out.
pg_dump + pg_restore finished. Exit code 0. Row counts match. Your database is not ready yet. One query, 250M rows, Postgres 18.6, cold cache: β†’ right after pg_restore: 32.6 s β†’ after ANALYZE: 6.1 s β†’ after VACUUM ANALYZE: 23 ms πŸ’₯ Same data. ~1,400Γ— faster. A logical dump does not carry the visibility map, and by default not the planner statistics. 25 of 28 migration guides we checked don't say to run VACUUM after the load. Before traffic: vacuumdb --analyze --jobs 4 then ANALYZE each partitioned parent All tests are reproducible, and the scripts are in the post (bonus: podcast episode) πŸ‘‡
4
2
25
1,846
pg_dump + pg_restore finished. Exit code 0. Row counts match. Your database is not ready yet. One query, 250M rows, Postgres 18.6, cold cache: β†’ right after pg_restore: 32.6 s β†’ after ANALYZE: 6.1 s β†’ after VACUUM ANALYZE: 23 ms πŸ’₯ Same data. ~1,400Γ— faster. A logical dump does not carry the visibility map, and by default not the planner statistics. 25 of 28 migration guides we checked don't say to run VACUUM after the load. Before traffic: vacuumdb --analyze --jobs 4 then ANALYZE each partitioned parent All tests are reproducible, and the scripts are in the post (bonus: podcast episode) πŸ‘‡
16
22
2
192
14,906
something spiked 10 minutes ago. pg_stat_activity already forgot. pg_ash remembers. Active Session History for any Postgres -- pure SQL, no extension, no restart. RDS, Cloud SQL, Supabase, AlloyDB, Neon. in 2.0 (currently rc1): - redesigned to be easier to use, for humans and agents - unified AAS metrics - up to 23x faster reads tested on PG 14–19rc1 free, Apache 2.0 setup: \i sql/ash-install.sql select ash.start('1 second'); github.com/NikolayS/pg_ash -- ASH for Postgres, in pure SQL
3
5
30
2,174
PostgresAI retweeted
New episode: "pg_stat_log" Nik and Michael are joined by @fabriziomello to discuss his new extension pg_stat_log. 🎧 postgres.fm/episodes/pg_stat… πŸ“Ί youtu.be/xr5kv1WUdWM
1
6
2
11
4,057
finally got dark theme in console.postgres.ai
1
10
1,086
PgQue got a website with docs – pgque.dev
5
32
219
14,234
"you can't have superuser" "you can't install that extension" "you can't access WAL" "it's for your protection!" no. it's free software -- handed back to you with the freedom removed, and the cage painted as safety Postgres is free. that freedom is the whole point. you don't need protection from the database you've run for decades. you need access to it. full control. and ownership.
2
3
44
4,724
PgQue v0.2.0: 🐍 Python, 🟦 TypeScript, 🐹 Go clients ⚑️ send_batch() performance optimized πŸ‘₯ subconsumers to scale consumption near-linearly ⏱️ sub-second ticking and 10 ticks/sec by default (incl. with pg_cron) 🧩 pg_cron, pg_timetable, pg_tle paths PgQue is a highly-efficient, zero-bloat Postgres queue built on top of on battle-proven Skype's PgQ. One SQL file to install, pg_cron to tick. Works in any Postgres.
5
7
44
2,454
pg_ash v1.4 is out β€’ Long-term rollups: 1-minute and 1-hour rollup tables for longer storage β€’ Configurable raw partitions: by default, 3 daily partitions, can be any number β€’ Safer destructive operations: explicit confirmations needed β€’ Hardened privileges: public access is restricted; guarded search paths; "ash.grant_reader('youruser');" β€’ Stronger release gate: CI covers PostgreSQL 14–18, pg_cron and no-pg_cron modes, e2e tests, etc. pg_ash is Active Session History (ASH) implemented in pure SQL/PLpgSQL β€” no C extension build, no restart, no shared_preload_libraries. Works in any Postgres. Ask your AI agent to inject it "\i sql/ash-install.sql" and then analyze workload using functions – your AI will figure it out easily.
1
7
34
2,153
Upcoming PgQue 0.2 introduces subconsumers (PgQ's "cooperative consumers", reimplemented due to license uncertainty) -- this is how you can scale consumption almost linearly PgQue is a very efficient, zero-bloat Postgres queue. One SQL file to install, pg_cron or pg_timetable to tick. Works everywhere.
2
5
47
5,639
PostgresAI retweeted
Replying to @samokhvalov
@samokhvalov you've done an amazing job with pgque. I ran a new comparison of postgresql based job-queue (ish) systems over the weekend.
1
2
14
1,258
PgQue v0.1.0 is out. PgQ -- the Postgres queue system built at Skype 20 years ago for 1B-user-scale workloads -- repackaged for the managed-Postgres era. One SQL file. No C extension. No external daemon. pg_cron to tick. Why bother reviving a 2007 architecture? Every major Postgres queue in production today uses some flavor of SKIP LOCKED + UPDATE/DELETE. It works under light load. When you have more data and higher load, it degrades predictably. Then you get posts like these: - Brandur at Heroku, 2015: 60k job backlog in one hour from a single open transaction - PlanetScale, 2026: death spiral at 800 jobs/sec - River issue #59, awa issue #169 and so on, Oban's partitioning work, PGMQ's autovacuum tuning guide and duct-taping with pg_partman The core issue is how Postgres MVCC is implemented and how we deal with it. Dead tuples in the hot path, xmin horizon pinned, vacuum falling behind, query performance quickly degrades. This happens every time you run pg_dump, execute an analytical query, or have a lagging/unused logical replication slot. PgQ solved this in 2007 with snapshot-based batching and TRUNCATE rotation -- zero dead tuples in the event path, by design. But PgQ needed a C extension and an external daemon. Which means it doesn't run on RDS, Aurora, Cloud SQL, AlloyDB, Supabase, or Neon -- i.e., where most Postgres lives now. PgQue closes that gap. πŸ’Ž Pure SQL + PL/pgSQL (PgQ engine) πŸ‘©β€πŸ’» \i sql/pgque.sql -- you're done πŸ•‘ pg_cron replaces pgqd (optional, recommended) πŸ’» Python, Go, TypeScript client examples shipped πŸ’™ Apache 2.0 Trade-off: end-to-end event delivery latency is up to a second, it depends on ticking frequency. If you need sub-3ms job dispatch, use River, Oban, or graphile-worker (and avoid anything that blocks xmin horizon). If you need high-throughput event streaming with fan-out inside Postgres -- Kafka-shaped, without Kafka and dealing with transactional outbox implementation -- this is the right shape of tool. Kudos to Marko Kreen and Skype engineers who implemented this decades ago, for the original PgQ, and to Alexander Kukushkin whose recent "Rediscovering PgQ" talk brought this quiet corner of the Postgres ecosystem back into view. Stars, issues, PRs, and honest criticism all welcome. Link πŸ‘‡
6
49
6
350
35,069
cooking - @postgres_ai DB health matrix
2
4
31
3,526
rpg 0.10 release has improvements /ash – redesigned navigation: - ← β†’ to pan through history - "cursor" to see wait event details for each ASH sample - zoom in/out are now on [ and ] And of course, there is new secret /rpg command. + a bunch of fixes and small improvements rpg is my FOSS experiment to rewrite psql in Rust, add TUI components, AI integration, ASH analysis, etc. – and eventually get modern CLI/TUI for Postgres
1
4
14
1,916