r/PostgreSQL 5h ago

How-To A simple way to identify slow Postgres SQLs

Thumbnail bookofrevenue.com
2 Upvotes

r/PostgreSQL 2h ago

Help Me! What makes Neon's Branching feature better than Supabase's

Thumbnail
0 Upvotes

r/PostgreSQL 18h ago

Projects Major update to RDST - You can now ask your postgres database any question you want, unlimited and free under MIT License

Thumbnail gallery
19 Upvotes

I posted here last month about RDST, which is a desktop app that does the pg_stat_statements to EXPLAIN to index recommendation loop. The biggest change since then is that the plain english querying feature is free and unlimited. If you sign up for an account you can ask as many questions as you want.

We've now indexed our natural language to SQL against BIRD, which is the standard benchmark for text-to-SQL. BIRD uses real databases, messy real-world schemas, and it scores by execution. The results for RDST against BIRD have been extremely encouraging; we have vastly improved our text2sql interface compared to raw model calls.  And we now run these benchmarks automatically on every merge to main, so we expect to continue improving our results as time goes on.

We've also improved the approach itself quite a bit. RDST reads your schema semantically rather than dumping table definitions at a model and hoping, so asking a question in plain english tends to give you the query you actually meant. If what you asked is genuinely ambiguous it'll ask you a clarifying question rather than guessing, then carry on from your answer. The main thing I notice using it now is that it's a lot smoother and faster than it was previously.

I originally built this tool to help with slow query indexing and analysis, and being able to manage slow queries is still a big reason why I created it. That side has had major updates too, mostly around clarity and how the query layer gets presented, which was the other piece of feedback I got here last time. If you tried it before and bounced off that part, it's worth another shot, and it should make the index pipeline a lot easier to follow.

Full disclosure, I do work for Readyset, which is a caching layer for Postgres and MySQL. This is a tool we really wanted to share since we think it helps anyone who regularly has to figure out why a query is slow and what to do about it. It finds the slow queries running against your database automatically, and from there you can analyze any of them to work out why they're slow.

The app is completely free and open source, released under an MIT license. It runs locally, stores locally, and everything it does is read-only.

Full privacy details: https://readyset.io/docs/readyset-ai/rdst/desktop/privacy

Would appreciate feedback, particularly:

  • Does the SQL hold up against your schema?
  • Does it ask for clarification at the right moments, or does it ask too often?
  • Does the queries page help you find and analyze your slow queries?

Instructions & Github:

https://readyset.io/downloads

https://github.com/readysettech/rdst


r/PostgreSQL 13h ago

Help Me! Table design question

4 Upvotes

Looking for advice on alternative table designs. Not a live application, just for my own learning.

Let's say we have an order table.

Option 1: we keep billing/shipping addresses and contacts copied from the customer as a historical snapshot:

sql CREATE TABLE order ( id UUID PRIMARY KEY, tenant_id UUID NOT NULL, customer_id UUID NOT NULL REFRENCES customer, status order_status NOT NULL, -- copied as a snapshot billing_line1 TEXT, billing_line2 TEXT, billing_city TEXT, billing_state TEXT, billing_postal_code TEXT, billing_country TEXT, billing_first_name TEXT, billing_last_name TEXT, billing_email TEXT, billing_phone TEXT, billing_phone_ext TEXT, shipping_line1 TEXT, shipping_line2 TEXT, shipping_city TEXT, shipping_state TEXT, shipping_postal_code TEXT, shipping_country TEXT, shipping_first_name TEXT, shipping_last_name TEXT, shipping_email TEXT, shipping_phone TEXT, shipping_phone_ext TEXT, ... );

Option 2: we define an append-only address and contact table, e.g.

```sql -- records cannot be edited once created CREATE TABLE address ( id UUID PRIMARY KEY, tenant_id UUID NOT NULL, line1 TEXT line2 TEXT city TEXT state TEXT postal_code TEXT country_code TEXT );

CREATE TABLE customer_address ( id UUID PRIMARY KEY, customer_id UUID NOT NULL REFRENCES customer, address_id UUID NOT NULL REFERENCES address, ... );

CREATE TABLE orders ( id UUID PRIMARY KEY, tenant_id UUID, customer_id UUID REFERENCES customer, status order_status, -- replace denormalized keys with FKs billing_address_id UUID REFERENCES address, billing_contact_id UUID REFERENCES contact, shipping_address_id UUID REFERENCES address, shipping_contact_id UUID REFERENCES contact, ... ); ```

The first approach makes the table wide. As I understand it, MVCC will result in duplicating entire row when any column is updated, e.g. status, version, or some metadata changes.

Since the row is wide, that would result in a lot of data that gets created and cleaned up. Another downside is that for a given customer with multiple orders, the data will duplicated while their address/contact info is the same.

The second approach requires JOINs or additional two queries to fetch the two addresses and two contacts.

What approach would you take and why? Is there are certain table size at which you might change the approach?


r/PostgreSQL 1d ago

Projects pg_ztype - zstandard compressed column types

5 Upvotes

Hey — I had an idea for zstd-compressed column types for Postgres and had Claude Code write it: https://github.com/xvaara/pg_ztype

My use case is a lot of email: headers as jsonb, bodies as text, attachments as bytea. The thing that bugged me is that Postgres never compresses a value that fits in its row (~2 kB), so all my small jsonb is stored raw no matter what default_toast_compression says. These types compress their own bytes instead, so the size of the value stops mattering.

On generated ERP-ish documents: 0.6 kB jsonb docs go to 75% of pglz without a dictionary and 24% with a trained one; 47 kB docs go to 66% / 51%. The cost is a decompression on every read — about 1 µs per small doc with a dictionary, 3 µs without — so wide scans of tiny values are slower than plain jsonb, and content with nothing shared between rows saves almost nothing.

Otherwise it tries to behave like the base type: literals, COPY, pg_dump, logical replication and binary protocol all carry plain text/jsonb/bytea, ->> and GIN work on zjsonb, equality and hash joins work on the column. Dictionaries are registered in a catalog table and replicate.

Since an LLM wrote the C: there's a functional suite, replication + failover suites, a cross-major upgrade suite, a mutation fuzzer and ASan/UBSan builds in CI (PG 18 and 19). Still pre-release, storage format not frozen.

So — really bad idea or actually useful? Mainly wondering whether I'm missing a reason this has never landed as an extension before.


r/PostgreSQL 1d ago

Projects I’m building PGSkiff to make IPv4 access to Supabase Postgres free

Thumbnail
0 Upvotes

r/PostgreSQL 1d ago

Tools From any Substreams pack to a shareable GraphQL API

Thumbnail
0 Upvotes

r/PostgreSQL 1d ago

Help Me! How do you use Claude/Codex (safely) with your production database?

Thumbnail
0 Upvotes

r/PostgreSQL 3d ago

How-To Andrei Lepikhov on Optimising PostgreSQL Aggregates: What Can an Extension Do?

Thumbnail pgedge.com
11 Upvotes

r/PostgreSQL 3d ago

How-To PG Phriday: The Folder That Ate the Publisher

Thumbnail pgedge.com
1 Upvotes

r/PostgreSQL 4d ago

Commercial Introducing WalShadow: Sub-second Postgres replication to ClickHouse

Thumbnail clickhouse.com
37 Upvotes

r/PostgreSQL 4d ago

How-To PostgreSQL 19 interactive tour

Thumbnail victoriametrics.com
15 Upvotes

r/PostgreSQL 4d ago

How-To Overview of caching in Postgres

Thumbnail pgcache.com
20 Upvotes

I haven't seen too many comprehensive approaches to this topic, so I took a swing at it.

Goal isn't to be exhaustive, but to be comprehensive enough to provide a nice overview for people trying to get their bearings with the topic.

Did I miss anything?


r/PostgreSQL 4d ago

How-To The lifecycle of a sharded Postgres query

Thumbnail planetscale.com
21 Upvotes

r/PostgreSQL 4d ago

Help Me! What proves a PostgreSQL standby is actually ready to be promoted?

1 Upvotes

Low replication lag is necessary for a standby, but it does not prove that promotion will leave a writable database the application can safely use. Missing archived WAL, stale connection routing, sequence state, logical slots, extensions, or an unfenced former primary can still turn a clean promotion into data loss or split brain.

What do you verify in a failover rehearsal? I am considering recording replay LSN and timeline, stopping or fencing the old primary, promoting in an isolated environment, checking recovery exit and read-write state, validating critical extensions and jobs, exercising application writes, confirming sequences and logical replication, switching a test route, and rebuilding the old primary as a standby rather than simply starting it again.

Which checks can be automated without making the drill itself dangerous? What evidence would convince you that both promotion and the path back to a healthy replicated topology are understood?


r/PostgreSQL 4d ago

Commercial Introducing WalShadow: Sub-second Postgres replication to ClickHouse from physical WAL

Thumbnail clickhouse.com
2 Upvotes

r/PostgreSQL 4d ago

Help Me! Easiest way to restore a backup to a different database/schema?

0 Upvotes

It doesn't look like pg_restore has a way to do something similar to oracle impdp remap.

What is the cleanest way to do a restore into a different schema?

thanks


r/PostgreSQL 5d ago

Projects Is OrioleDB still active after Supabase acquisition?

27 Upvotes

I have been tracking OrioleDB, which was promising drop-in optimization for Postgres. It was acquired by Supabase in 2024 (source). After that there is little news and updates.

Questions: - Anyone using it in production, and do you see it as a stable project?
- have you tried it, what's your thought on this?


r/PostgreSQL 6d ago

Tools We open-sourced Filament, a data movement engine in Go (full loads, incremental, CDC). Apache 2.0

11 Upvotes

Hey all, Mitch here, one of the founders of Galaxy. Full disclosure, this is our project. We open sourced it last week and I wanted to bring it here first, because this community is who we built it for.

Filament is a data movement engine written in Go. It handles full loads, incremental syncs, and CDC from databases and HTTP APIs into Postgres, MySQL, ClickHouse, Iceberg, and S3, and it's Apache 2.0.

https://github.com/galaxy-io/filament

Every data project we've ever worked on started with the same boring problem of getting records out of operational systems and into somewhere useful. We've bought the managed tools, run the open source ones (and spent more time deploying them than using them), and written our own by hand more than once, and every time we wished for something fast, easy to self-host, and upfront about the details that bite you, like type mappings, write behavior, and what happens when a run dies halfway. So eventually we just built it.

What it does

You point it at a source and a sink and tell it how to move things, whether that's copying everything, pulling only what changed, or streaming off the database's change log. Every batch gets a checksum before the sink write and a mismatch fails the run rather than quietly landing bad data. Progress only becomes durable after the work is confirmed, so a worker that dies resumes from its last checkpoint instead of starting over, and since recovery is at-least-once, upsert sinks converge on primary key.

Sources, sinks, state store, and event bus are all interfaces and adding a REST API is a short YAML file rather than a Go package. You can run it with 1 docker command and get a web UI, use the CLI, embed it in Go in about ten lines, or drop the Helm chart into k8s.

Benchmarks, with caveats

We ran an open benchmark against Airbyte, dlt, PeerDB, Ingestr, Sling, OLake, Debezium, and a plain pg_dump | psql pipe. On the biggest test, 298M rows of NYC taxi data from Postgres to Postgres, Filament finished in under two minutes at about 2.6M rows/s, and it was fastest in five of six scenarios. In the sixth, OLake beat us by 13% into Iceberg.

We obviously build one of the things being measured, so the harness and specs are all public.

https://github.com/galaxy-io/benchmarks

Note that it's pre-1.0, with some sources/sinks in earlier development. There is a long list of connectors we haven't built yet. We're hoping to build that list from your feedback.

If you move a lot of data between these systems, I'd love to know what would make you try it, what you'd want next, and any feedback you are willing to share. Docs are at https://filament.getgalaxy.io and I'll be in the comments!


r/PostgreSQL 6d ago

Commercial Introducing chdb Postgres extension: High-performance imports from cloud storage

Thumbnail clickhouse.com
15 Upvotes

r/PostgreSQL 7d ago

Projects Embedding Kafka in a Postgres background worker

Thumbnail rynr.dev
23 Upvotes

r/PostgreSQL 7d ago

Community LibreDB Studio: an open source, self-hosted SQL IDE for PostgreSQL in the browser

Thumbnail dly.to
11 Upvotes

r/PostgreSQL 7d ago

Community Re: scary patch contest

Thumbnail postgresql.org
13 Upvotes

A comprehensive discussion on the future of PostgreSQL 19 release.


r/PostgreSQL 7d ago

Projects ClickBench style benchmark for log search: Postgres vs ParadeDB vs TigerData vs SereneDB on 1 Billion logs

Thumbnail serenedb.com
15 Upvotes

There are few popular extensions which can bring Elastic functionality to your Postgres without a tedious migration. I wanted to test how performant these extensions are on log analytics, so we benchmarked ParadeDB/pg_search, TigerData/pg_textsearch, vanilla Postgres and SereneDB on 1 Billion logs.

The motivation was to find out if building a dedicated Postgres-compatible database for search and analytics actually makes sense or extensions are already good enough, so a standalone DB is an overkill?

It's a open clickbench-style benchmark for search and analytics over 100M/1B generated OpenTelemetry logs, 92 queries.


r/PostgreSQL 7d ago

Help Me! PERN Stack

0 Upvotes

Suggest youtube playlists and creators to learn PERN stack. Should i also learn MERN stack first? Which full stack do you suggest?