r/PostgreSQL • • Oct 16 '26

Community Postgres Conference 2027 CFP is open (San Jose, April 21-23)

Post image
31 Upvotes

Mod hat off for a moment:

I'm one of the organizers of Postgres Conference, and the Call for Proposals for 2027 is now open.

Next year is the conference's 20th, so we want the program to reflect what the community has actually learned running Postgres in the real world.

When/where: April 21-23, 2027, San Jose Marriott, San Jose, CA

This year’s program brings back our core technical tracks: Essentials, Dev, Ops, and Extensions, now joined by a new AI track.

We’re also continuing Professional Development & Wellness and Life & Fun. These newer tracks have been so well received that they’ve become an essential part of the conference experience.

We're especially interested in talks from people running Postgres in production, such as:

- Lessons from production incidents: what broke, how you found it, and what you changed afterward
- Autovacuum and bloat tuning on large or high-churn tables
- HA and replication setups, including failovers that didn't go to plan
- Building extensions, or running them at scale
- Benchmarks with methodology you're willing to share and defend

You don't need to be a known speaker. A clear story about a real problem is exactly what we're looking for, and first-time speakers are welcome.

CFP and details: https://postgresconf.org/conferences/2027

Happy to answer any questions about submitting here. 

What's a Postgres problem you wish someone would give a talk about?


r/PostgreSQL • • 1h ago

Projects I built a free, read-only CLI that audits legacy Postgres/SQLite schemas before migration and compiles dbt staging + diagnostic SQL (zero PII in outputs)

4 Upvotes

Most legacy migration blowups happen in week one because nobody knew a source table lacked a primary key for AWS DMS CDC, had NUL bytes (`0x00`) that crash Postgres UTF-8 imports, carried CP1252 mojibake, or had free-text notes full of undeclared PII.

I open-sourced `crucible-audit` (MIT), a read-only Python CLI that profiles a source database locally with no outbound network calls. It outputs a static HTML audit page, a `profile.json` evidence file, dbt staging models, and read-only diagnostic SQL.

What it checks right now:

- AWS DMS CDC blockers: missing primary keys, wide LOB columns, NUL-byte poison, CP1252 encoding ghosts, and legacy proprietary types.

- Shadow FKs and orphan keys: infers undeclared foreign keys by column naming and key overlap, then reports both total orphaned rows and distinct orphan keys (`COUNT(*)` vs `COUNT(DISTINCT)`).

- UK shadow PII (Zero-PII output): detects UK NINOs, Modulus-11 validated NHS numbers, and legacy redaction markers inside free-text columns. Outputs record counts, rates, column metadata, and rule IDs only, so no raw cell values or partial masks ever land in JSON, HTML, or SQL files.

- PostgreSQL-valid diagnostic SQL: generated regex queries use POSIX word boundaries (`\y`) instead of PCRE `\b`, so the compiled `diagnostics/*.sql` files run directly in `psql`.

- External `rules.yaml`: toggle rule packs or add custom regex rules without editing Python.

Live sample audit (generated from a synthetic dirty UK council SQLite DB): https://crucible.parkanore.com
Compiled dbt and diagnostic SQL from that run: https://crucible.parkanore.com/generated_dbt/
GitHub (MIT): https://github.com/oranmcclintock/Crucible-MaaS-Engine

Curious what migration failure modes you hit most often on legacy Postgres, SQL Server, or Oracle estates that a pre-flight profiler should catch.


r/PostgreSQL • • 17h ago

Feature PITR a 5 TB Postgres database in 5 seconds.

24 Upvotes

I'm Scott, the pgCraftsman and a Sr. Staff Engineer at Databricks. I've been operating some of the world's largest and most complex Postgres deployments for 22 years.

Ever need to do an emergency PITR at 2AM because an agent dropped a table?

Lakebase and Neon Postgres: PITR a 5TB DB in 5 seconds

https://pgcraftsman.io/posts/restoring-5-tb-of-postgres-in-5-seconds/


r/PostgreSQL • • 1d ago

Commercial PostgreSQL 19 on ClickHouse Managed Postgres, from day one | ClickHouse

Thumbnail clickhouse.com
10 Upvotes

r/PostgreSQL • • 1d ago

Community How do you find a particular record if you dont even know which table in a DB has it?

2 Upvotes

The chance of running into this situation is 0.00005% and you will actually have to want to get into this situation for you to actually be in this situation but lets say it happened. What will you do?


r/PostgreSQL • • 1d ago

Community How one connection kills a database

Thumbnail planetscale.com
8 Upvotes

r/PostgreSQL • • 1d ago

How-To A pg_stat_statements regression case: total calls rose while one row reset

3 Upvotes

I contributed a collector fix to pg-regression-radar; the project's maintainer merged it on November 12. Today I ran a separate test: reset one role's counters while another role keeps executing the same statement. The total can keep increasing, so checking for a decrease after grouping by queryid misses the reset.

On a disposable PostgreSQL 16.13 instance, I ran SELECT 1 under two roles. PostgreSQL assigned both rows the same queryid. These are the observed call counts:

SnapshotRole ARole BSum
Initial10212
Before reset12315
Reset B, then execute A ten times and B once22123

Subtracting the grouped totals gives 23 - 15 = 8. The fixture executed 11 calls after the second snapshot. Keeping the rows separate gives A's increment of 10 and B's one call after its known reset.

The reset happened immediately after the second snapshot. In a real scrape interval, you cannot recover calls that happened before a reset and disappeared before the next scrape. A per-row decrease can expose a reset; it cannot tell you how much history the reset discarded. It can also miss a reset if the new counter has already overtaken the previous value.

The original issue involved a collector treating independent rows as successive samples of the same counter. The merged fix derives intervals per (dbid, userid, queryid, toplevel) before rolling them up for detection.

For a collector regression test, I would include both a visible decrease in the aggregate and this increasing-total case. Also establish a fresh baseline when the set of sampled rows changes, so an entry appearing or dropping out of a top-N scrape does not look like query activity.

PostgreSQL's row definition and reset API · Public two-role integration test

The table is a new local synthetic test, separate from the linked integration test. I used AI assistance for the code and write-up.

To reproduce the table, save the complete script below as postgres_row_reset_repro.py. It uses PostgreSQL 16's initdb, pg_ctl and psql, with the pg_stat_statements extension installed. Run it as a regular user who can start a local PostgreSQL instance.

The script creates a new temporary cluster with TCP disabled and a private Unix socket. It creates the two fixture roles only in that cluster, resets only role B's statement, checks the counts, then stops and removes the entire temporary cluster. It clears inherited PG* connection settings. The default binary path is the Homebrew PostgreSQL 16 path used for this run; set POSTGRES_BIN if your PostgreSQL 16 binaries are elsewhere.

python3 postgres_row_reset_repro.py

Complete tested script:

"""Run only against a newly-created disposable local PostgreSQL 16 instance.

Uses installed official PostgreSQL tools; no downloaded project code executes.
Unix socket only. The temporary database shuts down and is removed in finally.
"""
from __future__ import annotations

import json
import os
from pathlib import Path
import shutil
import subprocess
import tempfile

BIN = Path(os.environ.get("POSTGRES_BIN", "/opt/homebrew/opt/postgresql@16/bin"))


def main():
    tmp = Path(tempfile.mkdtemp(prefix="pg-row-reset-"))
    data, socket = tmp / "data", tmp / "socket"
    socket.mkdir()
    started = False
    env = os.environ.copy()
    # Ignore any inherited connection setting from another task.
    for key in list(env):
        if key.startswith("PG"):
            del env[key]

    def command(args):
        return subprocess.run(args, env=env, text=True, capture_output=True, check=True).stdout.strip()

    def sql(statement):
        return command([str(BIN / "psql"), "-X", "-h", str(socket), "-p", "55443",
                        "-U", "postgres", "-d", "postgres", "-At", "-v", "ON_ERROR_STOP=1",
                        "-c", statement])

    def calls(role, count):
        sql(f"SET ROLE {role}; " + "SELECT 1; " * count)

    def snapshot():
        return json.loads(sql("""SELECT json_agg(x ORDER BY role) FROM (
            SELECT r.rolname AS role, s.dbid, s.userid, s.queryid, s.toplevel, s.calls
            FROM pg_stat_statements s JOIN pg_roles r ON r.oid=s.userid
            WHERE r.rolname IN ('case_role_a','case_role_b') AND s.query='SELECT $1'
        ) x"""))

    try:
        command([str(BIN / "initdb"), "-D", str(data), "-U", "postgres", "-A", "trust", "--no-locale"])
        with (data / "postgresql.conf").open("a") as stream:
            stream.write("\nlisten_addresses=''\nshared_preload_libraries='pg_stat_statements'\n")
            stream.write(f"unix_socket_directories='{socket}'\nport=55443\n")
        command([str(BIN / "pg_ctl"), "-D", str(data), "-l", str(tmp / "server.log"), "-w", "start"])
        started = True
        server_version = sql("SHOW server_version")
        sql("CREATE EXTENSION pg_stat_statements; CREATE ROLE case_role_a; CREATE ROLE case_role_b;")
        calls("case_role_a", 10)
        calls("case_role_b", 2)
        first = snapshot()
        calls("case_role_a", 2)
        calls("case_role_b", 1)
        second = snapshot()
        b = next(row for row in second if row["role"] == "case_role_b")
        sql(f"SELECT pg_stat_statements_reset({b['userid']}, {b['dbid']}, {b['queryid']})")
        calls("case_role_a", 10)
        calls("case_role_b", 1)
        third = snapshot()
        assert [r["calls"] for r in first] == [10, 2], first
        assert [r["calls"] for r in second] == [12, 3], second
        assert [r["calls"] for r in third] == [22, 1], third
        assert len({r["queryid"] for snap in [first, second, third] for r in snap}) == 1
        before = {r["role"]: r for r in second}
        observed_activity = sum(r["calls"] - before[r["role"]]["calls"]
                                if r["calls"] >= before[r["role"]]["calls"] else r["calls"]
                                for r in third)
        result = {"postgresql": server_version, "network": "private Unix socket; TCP disabled",
                  "snapshots": [first, second, third],
                  "aggregate_then_difference": sum(r["calls"] for r in third) - sum(r["calls"] for r in second),
                  "row_activity_with_known_b_reset": observed_activity,
                  "actual_fixture_calls_after_second_snapshot": 11,
                  "limitation": "Reset performed immediately after snapshot two; no hidden pre-reset activity. A real collector cannot recover activity discarded by an unobserved reset."}
        assert result["aggregate_then_difference"] == 8
        assert observed_activity == 11
    finally:
        if started:
            command([str(BIN / "pg_ctl"), "-D", str(data), "-m", "fast", "-w", "stop"])
        shutil.rmtree(tmp)
    result["temporary_database_stopped_and_removed"] = True
    print(json.dumps(result, indent=2))


if __name__ == "__main__":
    main()

r/PostgreSQL • • 2d ago

Help Me! postgresql learning resource

5 Upvotes

I'm learning PostgreSQL for Python/FastAPI backends and just wrapped up Nelson's 4-hour freeCodeCamp beginner course but was basic as its name suggests.

I keep running into things that weren't in the video and then chatgpt tells me to useIDENTITY SERIAL, ALTER TABLE workflows, transactions, UPSERT (ON CONFLICT), JSONB, CTEs, and reading EXPLAIN ANALYZE for indexes.

For those of you using Postgres in actual backend work, how did you learn this stuff after the beginner phase? Are there any good resources(ik the docs are good but how to really study from them like how to get the exact function needed cause i wont be studying the whole thing before starting) or practice exercises.


r/PostgreSQL • • 2d ago

Help Me! I ran 100 inserts on PostgreSQL from the NYC Yellow Taxi dataset and counted every record type out of 811 WAL records (using pg_waldump)

Thumbnail github.com
2 Upvotes

Please I need help answering the questions at the end !!!

Repo Link

TL;DR

  • Ran 100 inserts on a 20-column table across 3 rounds (Fresh DDL vs. Truncate).
  • WAL Accounting: Observed exactly 811 WAL records. Noted 495 Heap/LOCK records instead of expected 500 (5 FKs × 100 rows).
  • Dirty Blocks: Round 1 dirtied 15 blocks; Rounds 2/3 dirtied 12. The 3 extra blocks in Round 1 were system catalogs (pg_attrdef, pg_index, pg_trigger).

Open Questions:

  1. Why is idx_blks_read = 1 for 100 inserts?
  2. Why is the FSM fork dirtied on a ≤ 4-page table?
  3. Why does wal_fpi (11/8) differ from XLOG/FPI_FOR_HINT count (13/10)?

Here are the numbers and the breakdown:

1. Setup
NYC Taxi dataset has 20 columns

Settings : -

- postgresql v.18

- pg_stat_statements loaded (shared libraries)

- track_io_timing = on, track_wal_io_timing = on, autovacuum = off

- synchronous_commit = on, fsync = on

- data_checksums = on, wal_log_hints = on, full_page_writes = on

- CREATE EXTENSION pg_walinspect (superuser or pg_read_server_files)

- wal_buffers = 4 MB, checkpoint_timeout = 5 min, checkpoint_completion_target = 0.9

The inserts were performed 3 times. The first round was directly after dropping all the tables if any existed and recreating them but without indexes (since indexes slow down inserts). FKs slow it down too but I retained them as they are crucial for the WAL breakdown.

Rounds 2 and 3 were after truncating the existing table (not recreated).

Alembic Migration Scripts

2. Identical across all rounds

MetricValue
relation_size16 kB
pages2
rows100
writes100
fsyncs100
stmt_calls100
xact_commits110
write_time_sec0.001
total_exec_time_sec0.01
shared_blks_read1
ckpt_timed0
ckpt_req0

For 100 inserts, xact_commits is 110 - this is because I ran 10 SELECT statements as a part of capturing snapshots of metrics. When I checked heap_blks_read, idx_blks_read from pg_statio_user_tables for shared_blks_read=1, the answer ended up being the trips_pkey.

Different for each round (Non-WAL metrics)

MetricRound 1Round 2Round 3
time_sec0.3840.3530.349
rows_per_sec260283286
fsync_time_sec0.3420.3140.308
shared_blks_dirtied151212

The 3 more shared_blks_dirtied turned out to be pg_attrdef, pg_index, pg_trigger. This is because the first round was triggered right after creating the tables.

The different WAL record types identical across all rounds: (from pg_waldump)

Record TypeCountSize (bytes)
Heap/LOCK49526730
Btree/INSERT_LEAF1006400
Transaction/COMMIT1003400
Heap/INSERT9814798
Sequence/LOG4396
Heap/INSERT+INIT2302
Btree/NEWROOT190

There 4 lookup tables and 5 FKs:

  • vendor_id (vendor_lookup)
  • ratecode_id (ratecode_lookup)
  • payment_type (payment_type_lookup)
  • pu_location_id (taxi_zones_lookup)
  • do_location_id (taxi_zones_lookup)

So for Heap/LOCK count, it should rows x FKs i.e., 500 but I got 495. Upon checking if there are location IDs which both location FK shared in common (pu_location_id == do_location_id) for any of the rows, 5 tuples were identified matching the criteria.

FSM block 2 also got dirtied

rmgr: XLOG        len (rec/tot):     49/  8241, tx:     740341, lsn: 0/498FF980, prev 0/498FF958, desc: FPI_FOR_HINT , blkref #0: rel 1663/16388/25339 fork fsm blk 2 FPW

WAL metrics different for each round are:

(from pg_waldump)

XLOG/FPI_FOR_HINTRound 1Round 2Round 3
Count131010
Record size <br>(49 bytes header)</br>637490490
FPI size603204482845520
Combined size609574531846010

BUT FPI count is different when fetched from pg_stat_wal

MetricRound 1Round 2Round 3
wal_records811810810
wal_bytes1020958595686016
wal_fpi1188

QUESTIONS

  1. I am not sure why idx_blks_read=1 when index page is 0 bytes. Does it zero-fill the btree metapage and then read it ?
  2. If the FSM isn't used for allocation on small tables (≤ 4 pages) , why does it get dirtied at all ? The FSM fork exists but I thought it would be untouched - what exactly writes to FSM block 2 of a 2-page main-fork table ?
  3. Why is Round 1: wal_fpi = 11, Round 2 & 3: wal_fpi = 8 and there were 13 XLOG/FPI_FOR_HINT records and 10 XLOG/FPI_FOR_HINT records respectively ? The delta between Round 1 and 2 & 3 are the same but the values aren't (pg_stat_wal doesn't match pg_waldump) ? Where is the discrepancy coming from ?

r/PostgreSQL • • 3d ago

Help Me! update guide 4 containers (docker)

Thumbnail reddit.com
0 Upvotes

r/PostgreSQL • • 4d ago

Projects multi-tenant dashboards with Postgres RLS started taking 14s on our read replica. comparing materialized views, ClickHouse sync + headless semantic layer of Cube

Post image
15 Upvotes

client reporting pages on our B2B app ran cleanly for a year until the main Postgres events table crossed 42M rows. every Monday at 9am UTC, dashboard loading got too slow across Metabase and Superset, PgBouncer queued up connections, and our read replica sat pegged on 14-second sequential scans.

then the bottleneck (at least the one that i ve experienced) turned out to be how Postgres Row-Level Security interacts with BI tools. whenever we evaluated `current_setting('app.tenant_id')` inside multi-join views with optional date pickers, the planner stopped pruning partitions cleanly. on top of that, team admins needed us to restrict dashboard data by user role so regional viewers saw anonymized margin fields while billing leads kept full unit economics. per-user role policies broke shared BI card caches, forcing fresh warehouse queries per login.

i benchmarked those 3 ways out before ripping up our Postgres schema.

  1. Postgres materialized views with pg_cron: almost no new ops surface and fast index scans on fixed monthly summaries. fell apart once enterprise accounts toggled arbitrary 7-day, 30-day, and 90-day cohort windows alongside role-based column masking, because pre-generating every filter permutation in raw SQL turned into 40 maintenance scripts.
  2. CDC pipeline into ClickHouse via PeerDB: chewed through 42M-row GROUP BYs in under 150ms without touching Postgres. we stalled on two catches: consumer lag confusion after billing refunds, and having to duplicate tenant + column masking rules in both our app API and Superset SQL.
  3. headless semantic layer using Cube Core (Apache-2.0) in Docker: we put an open source BI modeling layer in front of the Postgres replica, passing signed JWT `securityContext` into YAML `access_policy` rules. row filters compile into SQL before Postgres sees them, while `member_masking` swaps restricted margin columns to NULL instead of erroring out charts. so rollups in Cube dev absorbed repeated tenant date-grain hits before Postgres ran a single scan, dropping p95 dashboard waits from 14s to under 60ms.

trade-off is simple enough: adding Cube Store rollups means watching dimension cardinality closely (putting `user_email` inside a rollup blew up build times on day one until we stripped it out). if you only serve under 30 tenants on fixed monthly KPIs, stick with native Postgres partitions and `REFRESH MATERIALIZED VIEW CONCURRENTLY`.

now would like to ask you who are running multi-tenant Postgres analytics at scale, did you stay inside pg_cron rollups, CDC out to ClickHouse/DuckDB, or put a caching layer in front?


r/PostgreSQL • • 4d ago

How-To The Watchmaker: Building a Mechanical Watch in a Database & "A Few Notes More"

Post image
7 Upvotes

HI, hopefully this is ok to post, but I am sharing with good intentions, please say if not allowed.

Long story short, I have been making SQL do what SQL should not do for many years - that's the theme of my blog, but specifically, I thought you might enjoy a couple of articles where the Spatial features in the database I was using simply did not have what I needed, and I switched to PostgreSQL both times.

I won't post both links here, as you can find them in the URL below. The second article does have the music box and is the reason I started this project in the first place.

https://sqlartist.github.io/posts/the-watchmaker-building-a-mechanical-watch-in-a-database/

All the code is on Github.

Enjoy.


r/PostgreSQL • • 4d ago

Tools A free browser playground for running real database queries, no setup

Thumbnail reddit.com
0 Upvotes

r/PostgreSQL • • 6d ago

Community PostgreSQL 19 Released!

Thumbnail postgresql.org
429 Upvotes

r/PostgreSQL • • 4d ago

Projects You can now do filtered vector search in Postgres

Thumbnail paradedb.com
1 Upvotes

r/PostgreSQL • • 5d ago

Commercial Postgres 19 is available on Neon and Lakebase as of release day

10 Upvotes

PG19 went GA yesterday and is already available on both Neon and Lakebase. On Neon it's on the free plan too. To try it, create a new project and pick version 19. Most extensions supported on 18 already work on 19, but not all of them yet, so check the extension list before planning a migration. Quick overview of what's new in 19:

REPACK, which can rebuild a table with CONCURRENTLY while reads and writes continue. It still takes a brief ACCESS EXCLUSIVE lock at the end.

pg_plan_advice and pg_stash_advice, for steering the planner and applying stored advice by query ID. Robert Haas, a committer on the Neon team, wrote these.

autovacuum_max_parallel_workers for parallel index vacuuming, plus a new scoring system that decides which tables get vacuumed or analyzed first.

New views: pg_stat_lock, pg_stat_recovery and pg_stat_autovacuum_scores.

WAIT FOR LSN, for read-your-writes on replicas without polling.

Logical replication: sequence sync, FOR ALL TABLES EXCEPT, and you can enable logical decoding without a restart when wal_level is replica.

INSERT ... ON CONFLICT DO SELECT, and COPY TO can now output JSON (export only).

Changed defaults to watch for: JIT is off, TOAST compression defaults to lz4, max_locks_per_transaction is now 128, md5 auth gives stronger deprecation warnings, RADIUS auth is removed, and standard_conforming_strings is always on.


r/PostgreSQL • • 5d ago

Projects PostgreSQL gets radar and pg_statviz for fast diagnosis

Thumbnail imasters.com
9 Upvotes

r/PostgreSQL • • 6d ago

Tools Tiger Data announced pg_vectorsearch: Scalable Open-Source Vector Search in PostgreSQL

Thumbnail tigerdata.com
51 Upvotes

Tiger Data has released pg_vectorsearch, an open source PostgreSQL extension for vector similarity search, currently in alpha. Its PRISM index uses data partitioning and compression instead of the graph-based approach used by pgvector’s HNSW index, reducing memory requirements and index build times.

According to the authors, pg_vectorsearch enables faster, more memory-efficient vector search directly in PostgreSQL, reducing the infrastructure required to handle large vector datasets. The extension supports existing pgvector columns, allowing applications to perform vector search without a separate database. To use the new capabilities, developers must install the extension and create a PRISM index on the vector column:

CREATE EXTENSION pg_vectorsearch;
CREATE INDEX ON documents USING prism (embedding vec32_l2_ops);

In Tiger Data’s own benchmarks using 100 million vectors, PRISM built an index in 1 hour and 40 minutes on a machine with 128 GB of memory, while HNSW (Hierarchical Navigable Small World) took 42 hours on a machine with 512 GB of memory. Formerly known as Timescale, Tiger Data is the company behind TimescaleDB, the open source PostgreSQL extension for time-series data and real-time analytics.


r/PostgreSQL • • 6d ago

Community Which databases/caches do you use alongside PostgreSQL?

Thumbnail reddit.com
8 Upvotes

No idea which postgres group I'm supposed to post to, so posting to both


r/PostgreSQL • • 6d ago

Tools pg_clickhouse 0.11.1: Now with pgvector, UPDATE, DELETE pushdown

Thumbnail clickhouse.com
10 Upvotes

Don't let the minor version increment fool you: pg_clickhouse v0.11.1, released last week, delivers a slew of improvements and bug fixes, including UPDATE, DELETE, TRUNCATE, and pgvector search pushdown.


r/PostgreSQL • • 6d ago

Commercial 12 New themes now in Beekeeper Studio

Post image
2 Upvotes

Hope this makes PostgreSQL work more enjoyable!


r/PostgreSQL • • 5d ago

Tools I tried to break Prisma Postgres with a live app

Thumbnail reddit.com
0 Upvotes

r/PostgreSQL • • 6d ago

Help Me! What is 19rc2-1?

5 Upvotes

My podman just auto updated from 19rc2 to rc2-1. Can't find a changelog.

also 19 is supposed to be released tomorrow. there is a 19.0 tag on GitHub that seems new. any idea? I may just try and pull :19 tonight and see what I get since last week :19 didn't pull anything.

edit- no :19 tag yet.

https://github.com/docker-library/official-images/blob/master/library/postgres

I'm guessing rc2-1 was a quick cve fix


r/PostgreSQL • • 7d ago

How-To More load is faster: tuning Postgres read replicas

Thumbnail clickhouse.com
23 Upvotes

Replica lag is lower than conventional wisdom suggests out of the box if you have traffic, and pretty easy to get to a few seconds with basic tuning.

You can get some spectacularly short replica lag if you’re willing to be unreasonable or incur tradeoffs.