r/postgres • u/merlinm • 4h ago
r/postgres • u/easybits_ai • 14h ago
Discussion Storing generated PDFs in Postgres vs object storage: where do you draw the line?
👋 Hey postgres Community,
Follow-up on the approval system I posted about last week. One decision I made this week that I am still not sure about.
The workflow generates a final PDF once Finance approves a request. People download it from a portal afterwards, sometimes repeatedly, sometimes months later. Regenerating on every download meant paying for the conversion again and making them wait several seconds each time.
So I cache it: the PDF is generated at the moment of approval and stored as base64 in a column on the fact sheets table, then served from there.
What I think I got right
Generating at approval rather than on demand means the document always carries the real approval timestamps, and I never pay twice for the same conversion. Caching any earlier would have meant storing drafts that never got approved.
What I am less sure about
Base64 in Postgres is simple. Everything lives in one place, no extra service, no signed URLs, no bucket permissions. But it is blobs in a relational database, and I have not yet hit the point where row sizes start to hurt. The alternative is object storage with a reference in the row, which is more correct and also more moving parts for something a handful of people download a few times a month.
Where would you draw that line? Curious whether people go to object storage from day one or wait until something actually breaks.
Best,
Felix
r/postgres • u/harulogs • 3d ago
Discussion DBerio update: what I changed after your feedback on my SQL client
About a month ago, I posted my SQL client, DBerio, here and asked for feedback. A lot of you took the time to reply, and your comments helped shape this update. Same disclaimer as last time: I'm a solo developer from Korea, this is self-promo, and I use a translator to write.
Things you asked for
- u/MrRoy_SQL asked for a visual EXPLAIN. The Profiler tab now shows PostgreSQL, MySQL and MariaDB plans as a tree, highlighting the slowest step and points to check. You can also summarize a plan on one page and print it or save it as a PDF.
- u/vincent_sch pointed out that EXPLAIN ANALYZE runs the statement, so analyzing an UPDATE would change data. On PostgreSQL, measured plan runs now use a read-only transaction, so the server blocks writes. Statements containing functions that a read-only transaction can't stop, such as ending a session, ask for confirmation first. Thanks for catching that. It was a real hole.
- DROP, TRUNCATE and ALTER … DROP statements run from the editor now ask for confirmation. If the connection is marked as production, you also have to type the target name.
Other changes
- Long text and JSON from the result grid now open in a larger Value Editor, with line numbers, search, JSON error locations and an editable JSON tree. Big integers and long decimals keep their exact digits.
- There's a dark mode now.
- If a connection drops, it reconnects when you expand the object browser or open a table, as well as when you run a query.
- Fixed a bug where "Discard Edit" in the grid saved the value instead of discarding it. Sorry about that one.
- Commit, Rollback and autocommit no longer hang while a long query is running.
Searchable query history across connections and a side-by-side diff of two result sets are still on my list. I haven't finished them yet.
Since 1.2.0, the app sends basic usage statistics: days opened, app version, OS and language. It never sends query text, connection details, table names or data, and you can turn statistics off in Settings.
DBerio is available on Mac and Windows and supports MySQL/MariaDB, PostgreSQL, SQLite and Redis. The free version includes every feature, with up to 3 saved connections and 2 open at once.
- Mac App Store: https://apps.apple.com/app/id6819625601
- Microsoft Store: https://apps.microsoft.com/detail/9N53NQGJ3TNG
If you find a bug, notice something that feels off, or have a feature in mind that would make you switch, please comment here or send me a DM. The fixes above started with comments like those, so please keep them coming.
r/postgres • u/scotterockaroo • 6d ago
Performance PITR a 5 TB Postgres database in 5 seconds.
reddit.comr/postgres • u/dorseygregor4 • 6d ago
Discussion Best database IDE for SQL Server and PostgreSQL? It depends on what you give up
If your team runs SQL Server and PostgreSQL side by side, you've probably had the "can we just use one toolset" conversation. There isn't a best database IDE for every team, but there are four common setups, and each one gives up something.
| Setup | What works well | What you give up |
|---|---|---|
| Native tools per engine: SSMS + pgAdmin | Free, complete coverage of each engine, official tooling | Two very different UIs and shortcuts, no shared way to compare or automate |
| One multi-database client: DBeaver, DataGrip | One app, one window, same shortcuts for both engines | Engine-specific depth varies. Things like T-SQL debugging or SQL Server-specific tooling may be thinner than in focused tools |
| Engine-specific IDEs from one vendor: dbForge Edge | Depth per engine with the same UI conventions and one license. Compare, data generation and CLI automation work the same way on both | Separate apps per engine, not one window, but unified interface |
| Mixed: native tools for admin, IDE for development | Each task gets a tool built for it | More tools to install, license and keep updated |
Trade-offs that come up in practice
One editor doesn't mean one language. T-SQL and PL/pgSQL differ in procedures, error handling, identity vs serial columns, and temp tables. A shared IDE makes the UI consistent, but you still write two dialects.
Moving data between the two engines is a separate problem. Type mapping, collations and case sensitivity cause most of the pain, and an IDE won't solve them on its own.
A quick way to decide
If most of your time goes into writing queries across both engines, one multi-database client is probably simplest. If you do deeper work on each engine (compare and sync between environments, profiling, test data, scripted deployments), engine-specific tools usually hold up better, whether they come from one vendor or from two.
If you run both engines, which setup did you end up with and why?
r/postgres • u/RaymondArtin • 6d ago
Discussion How are you sandboxing local LLMs with SQL access? I open-sourced a local Layer-4 Postgres proxy ("SQL Guillotine") to block hallucinated DROP/DELETE queries
Hey everyone! Lately I've been wiring up AI agents (Gemini CLI / MCP servers, LangChain, CrewAI, and smaller quantized local models) to PostgreSQL so they can actually read and write data—not just run read-only queries.
The scary part is obvious: one bad hallucination and the model runs a `DROP TABLE`, wipes rows with a `DELETE` missing a `WHERE` clause, or gets stuck in an infinite tool-calling loop. Asking a second LLM to double-check every SQL query adds too much latency, and regex filters break easily.
So I built Aegis, an open-source Go proxy + Python SDK that acts like a two-layer seatbelt sitting between your AI agent and Postgres:
• Layer 1 — Instant Copy-on-Write (CoW) Sandboxes: Using a one-line Python decorator (`@safe_db_run` in `aegis-sdk`), Aegis can spin up an instant, throwaway Copy-on-Write database branch (via Neon) for each agent run. Your agent gets full read/write freedom on an isolated clone, and the branch self-destructs when the run finishes so production data is never touched.
• Layer 2 — "The SQL Guillotine" (100% Local Docker Proxy): You just point your Postgres connection string to port `5433` instead of `5432`—zero changes to your app or MCP config. Aegis parses every query in memory using Postgres's real parser (compiled to WebAssembly) before your DB ever sees it. Normal queries pass right through, while `DROP TABLE`, `TRUNCATE`, or unfiltered `DELETE` statements get severed immediately.
• Runaway Loop Protection (Offline): If an agent gets stuck repeating queries in a loop, Aegis enforces local rate limits via a simple `policies.yaml` file (no cloud dependencies or Redis required) so it won't lock up your machine or burn through DB compute.
GitHub Repo (100% open-source): https://github.com/raymondhani/aegis-proxy
Curious how everyone else here is safely giving Gemini / MCP / local agents write access to databases right now—are you spinning up throwaway containers/branches, sticking strictly to read-only views, or building custom tool wrappers?
r/postgres • u/thisismugisha • 7d ago
Debugging Text column is storing accented text weirdly
I have a column of type TEXT where I could store text such as “Quarteirão” or “Católica”. However, the text is actually being stored as “Quarteirπo”, or “Cat≤Lica”
The SQL of the database goes something like:
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_defaultand the column in question is:
column text COLLATE pg_catalog."default" NOT NULL,I'm new to PostgreSQL, so I don't know what to change to store the text as is. I did check whether it was being changed before being inserted into the database, and it isn't being changed. It is the database that's not storing it how I expect it to.
r/postgres • u/Global-Apartment-872 • 8d ago
Tools Foreign keys for array column elements
reddit.comr/postgres • u/Global-Apartment-872 • 8d ago
Tools Foreign keys for the elements of an array column
Postgres can't put a foreign key on the elements of an array column. A FOREIGN KEY
constrains the whole column value, and that value is the array, not the IDs inside
it. So you can store an ID that doesn't exist, and deleting the referenced row
leaves every array still holding it.
pg_anyfk adds it:
SELECT anyfk.add('orders(product_ids)', 'products(id)', on_delete => 'scrub');
CHECK IT OUT: https://github.com/Vinnu124/pg_anyFK
r/postgres • u/UpstairsPrimary7449 • 8d ago
Performance Two production CAP traps I rarely see covered in interview guides (MySQL Group Replication reads & Cassandra QUORUM)
Most CAP explanations stop at labeling MySQL "CP" and Cassandra "AP", which falls apart once you look at default configs:
1. MySQL Group Replication is CP on writes, not reads by default. A 2-of-3 majority commit guarantees two nodes certified the transaction, but the third node can still lag slightly while applying its queue. Because group_replication_consistency defaults to EVENTUAL, a normal read on that lagging node still returns stale data unless you route critical reads to the primary or enable BEFORE_AND_AFTER.
2. Cassandra W=QUORUM + R=QUORUM is not strict linearizability. If a coordinator writes to R1 and crashes before reaching R2/R3, the client sees a write error — yet a subsequent quorum read hitting R1 triggers read-repair and resurrects the "failed" write. True linearizability requires Paxos Lightweight Transactions (SERIAL).
If anyone prefers a visual walkthrough of these failure modes alongside the 2018 GitHub 43-second partition and PACELC, I put together an animated deep dive here: https://youtu.be/17j1S5OOOAM
r/postgres • u/philippemnoel • 10d ago
Discussion You can now do filtered vector search in Postgres
paradedb.comr/postgres • u/shibi__dev • 11d ago
Discussion PostgreSQL 19: Read from Replicas Without Missing Recent Writes
PostgreSQL 19 introduces WAIT FOR LSN, helping applications handle replication lag in asynchronous replicas.
When an application writes data to the primary database and immediately reads from a replica, the latest changes may not yet be available.
WAIT FOR LSN allows the replica to wait until it has replayed the required changes before processing the read.
In simple terms: Write to the primary → Wait for replication → Read from the replica.
This makes read-your-writes consistency easier to achieve without routing every read to the primary.
#PostgreSQL #DatabaseEngineering #SystemDesign #SoftwareEngineering
r/postgres • u/rathboma • 11d ago
Question Which databases/caches do you use alongside PostgreSQL?
I mostly hear about folks using Redis/Valkey or Memcached for caching, but curious what other DBs most folks use alongside PostgreSQL.
In particular - anyone using Snowflake, BigQuery, DataBricks, something else?
Context: I make Beekeeper Studio, an open source database GUI focused on being fast and intuitive. One of our strengths is to be a pleasant and consistent UI for ANY database.. So wondering what the 'any' is for you all.
I personally use PostgreSQL with Redis.
r/postgres • u/mariiiiiiiiiiiiiiiel • 11d ago
Question sslmode value in production when inside a docker container
i have a docker stack with a postgres image, is it completly necesary to have the postgres to be configured with the ssl mode to verify-full , because, the outside world cannot interact with the db, just the backend server can (the network is not attachable and it doesn't expose any ports)
im pretty sure there is a thing im not seeing for this so that's why i am asking, sorry if docker being involved is kind of topic in the subreddit but my guess is that a lot of people also use postgres within a container
r/postgres • u/Mindless-Piece-47 • 11d ago
Performance Hunting Performance Regressions Through Years of MariaDB History
r/postgres • u/gubinanuwu025 • 11d ago
Tools Looking for a pgAdmin alternative? Start with what you use it for
If pgAdmin is starting to feel more like a hurdle than a full toolkit, this is worth a look. The honest answer depends on which part of pgAdmin you want to replace. pgAdmin does two quite different jobs: server administration and SQL work. Most people who want to switch are unhappy with one of them, not both.
If you're mainly doing admin work
Keep pgAdmin. It's free, open source, developed alongside the PostgreSQL community, and it covers roles, backups and restores, maintenance, server dashboards and a lot more. Many DBAs combine it with psql and don't look further. Most alternatives below are weaker here.
If you mainly write SQL
This is where alternatives matter most. Things to look for are completion that knows your schema, formatting you can share with the team, query history, and a way to profile and compare query performance.
DataGrip is a good fit if your team already uses JetBrains ecosystem. It's cross-platform and commercial. DBeaver is open-source and connects to many databases, and the Community edition is free. dbForge Studio for PostgreSQL has a free Express edition as well. Its focus is SQL development and data tasks: completion, formatting, Query Profiler, schema and data compare with sync scripts, test data generation and reports.
If you mostly view and edit data
A lightweight client will probably feel better than any IDE. TablePlus, Beekeeper Studio, or Postico if you're on a Mac. They open fast and stay out of the way.
The common setup
A lot of teams end up with two tools: pgAdmin or psql for admin, and a separate editor or IDE for daily SQL. That's not a compromise, it's just matching the tool to the job.
If you need strong development and management tool, dbForge, Studio for PostgreSQL covers all common scenarios
What's the part of pgAdmin that bothers you most?
r/postgres • u/OrbeoMe • 12d ago
Performance A Postgres RLS fix made opening a chat 40× faster (117 ms → 3 ms)
Small dev note from building Orbeo, my messenger. Chats were slow to open, and I expected the network or the phone to be the problem. It was the database access rules (Row Level Security in Postgres).
The rule "only members can see a conversation's members" called a check function for every row. In a conversation with hundreds of people, that's hundreds of function calls per query: 117 ms.
The fix: the function now returns the whole set of the user's conversations, and the rule just checks membership in it:
using (conversation_id in (select my_conversation_ids()))
Postgres evaluates that subquery once and matches rows against a hash table. Same query: 3 ms. We used the same trick for message search.
Lesson: if an RLS policy calls a function per row, check how often it runs before blaming the network. 🙂
r/postgres • u/HistoricalRuinny • 12d ago
Question Where do you develop most of your Postgres databases?
Trying to get a sense of how people actually work with Postgres day to day. If you use more than one, pick the one you spend most time in and mention the rest in comments.
r/postgres • u/lucianboboc • 13d ago
Tools I built PGZen, a native PostgreSQL client for macOS — launched today on Product Hunt
Hey everyone!
I'm an independent developer, and I've been working on PGZen, a native macOS application focused entirely on PostgreSQL.
It includes a SQL editor with autocomplete, database exploration, ER diagrams, execution plan visualization, and safe database editing.
I wanted to build something that feels at home on macOS while providing useful tools for PostgreSQL development.
PGZen is now available on the Mac App Store, and I launched it on Product Hunt today:
https://www.producthunt.com/products/pgzen
I'd love to hear what PostgreSQL developers think and which features they'd find most useful.
Thanks for checking it out!
r/postgres • u/Downtown-Warning6818 • 13d ago
Question I'm Planning to Build Something Around PostgreSQL Maintenance – Where Should I Start?
Hey everyone!
I'm exploring the idea of building a tool or service focused on PostgreSQL maintenance and database management.
I'm particularly interested in solving real-world operational challenges such as:
- Vacuum and autovacuum management
- WAL growth and disk space management
- Index bloat detection and cleanup
- Query performance monitoring
- Connection management and troubleshooting
- Backup, recovery, and database health monitoring
I'd love to hear from people who work with PostgreSQL in production.
A few questions:
- What are the biggest PostgreSQL maintenance challenges you face?
- Which repetitive DBA tasks do you wish could be automated?
- Are there existing tools that solve these problems well, or are there gaps worth exploring?
- If you could have one tool to make PostgreSQL operations easier, what would it do?
I'm looking to understand actual pain points before jumping into development.
Would love to hear your experiences and suggestions! 🙌
r/postgres • u/briandiaz6 • 13d ago
Discussion PostgreSQL 19 is almost here. Are you planning to upgrade?
PostgreSQL 19 is scheduled for release on November 19, just a week after PostgreSQL 14 reached its end-of-life date. I've been looking through the upcoming changes, and a few things caught my attention.
What's interesting in PostgreSQL 19:
- REPACK (CONCURRENTLY) should make it easier to rebuild bloated tables without blocking regular reads and writes.
- Autovacuum improvements include parallel index cleanup and better prioritization.
- Foreign key checks have been optimized, which could help with write-heavy workloads.
- The query planner gets some improvements, including optimizations for certain NOT IN queries.
There are also a few compatibility changes worth checking before upgrading:
- JIT is now disabled by default.
- MD5 authentication produces warnings.
- Some configuration defaults have changed.
- Certain older database configurations may cause issues with pg_upgrade.
Personally, I think the more interesting question isn't whether PostgreSQL 19 has enough new features, but whether there's a good reason to upgrade immediately.
If you're still running PostgreSQL 14, moving to a supported version is obviously more urgent. But for teams already on 17 or 18, waiting until PostgreSQL 19 has had a few updates might make more sense.
What's your upgrade strategy? Are you planning to test PostgreSQL 19 as soon as it's released, or are you sticking with your current version for now?