MICHAEL WINTERS

New FOSS project: the Postgres Dump Tool (pgdt)


For the impatient, just see: pgdt.

The Situation #

In the Fedora Data Working Group (FDWG) I’m running a single-node Kubernetes cluster to provide all services, including data engineering pipelines, analytics, OIDC, etc etc, mainly because that’s all I can personally afford. (Hire me!) Suffice to say: compute resources are tight in this environment.

The upstream Fedora data that we ingest is primarily made available as full backups of their Postgres databases. This is done with a tool called pg_dump, so these files are generally referred to as “dumps”. For the main databases, these dumps are huge because they contain the entire history of Fedora, e.g. all the details about a software build which occurred 10 years ago.

“All of the history” is incredible from a data science perspective. And terrible from the perspective of, “I had ‘all the history’ a week ago, now I just need last week’s history.”

Too bad, you get to:

  1. Spin up a reasonably-sized Postgres, consuming a significant percentage of your precious RAM budget.
  2. Restore the entire history from scratch (consuming several terabytes of disk and 1-2 days of waiting).
  3. Finally, extract just last week’s data (roughly 10 minutes of work).
  4. Throw it all away and repeat next week.

Oh, and you get to repeat that process for each database, making it almost impossible to run this process across all databases in a single week.

The Revelation #

Parquet is just “some data” + “some statistics about that data”. Those dumps contain the data. (Sure, not in an ideal format, but certainly in a workable format.)

All we need to do is add the metadata.

The Exhalation #

I’ve been using Claude Code extensively in my personal work. That’s not entirely by choice as a job seeker – I’ve already been turned down once for not being “AI native” enough. And while I must admit that as a GSD-type person the results and velocity are thrilling, the downsides are also absolutely horrific.

It’s amazing what we’ll accept to put food on the table for our kids.

So, anyway!! Let’s vibe up some metadata, shall we?

I care deeply about code quality. And I’m sure I’m not the only one with this data problem, so I don’t want to inflict bad vibes on anyone else. In other words, I want to find a way to keep a tight grip on architecture and quality while still letting the methane LLM do the grunt work.

I think I’ve generally succeeded in this. I agreed to meet the LLM halfway and allow it to retain some extensive historical records, which does make the git log rather noisy, but seems to lead to steady progress forward. We’re now regularly producing code that I’d accept.

Not always, mind you – we kind of tick-tock between “make it functional” and then “make it clean”, but to some extent that’s a natural dev flow anyway. Just don’t judge it until I call it v1.0.

The Excitation #

Once you have some statistics about your data, you need a way to query it. There are a lot of options here, but I chose to integrate Apache DataFusion which is a Rust-native query engine designed for exactly these sort of shenanigans. pgdt sql gives you a full SQL REPL ala psql, using Datafusion’s SQL dialect.

Look ma, no daemons!

The Celebration #

It seems to have been well worth the effort. The final results for my “weekly extract to Parquet” job are quite astounding by time measurement alone:

Not to mention that I can now delete Postgres from our tiny instance, freeing up RAM for many other services and capabilities.

The Relaxation #

I plan to continue to flesh out pgdt to support additional use cases and possibly more integrations e.g. into DuckDB, Trino, etc. And hopefully it will become useful to others. If I’m going to consume from the commons, I’m glad that perhaps the commons can derive some of the benefit.

If that turns out to be you, drop me a line!

#opensource #data