r/postgres • u/pmz • Apr 24 '20
supabase/postgrest-js Isomorphic JavaScript client for PostgREST
r/postgres • u/pmz • Apr 24 '20
r/postgres • u/m1ss1l3 • Feb 22 '20
I manage a SaaS with about 1700 users and currently we use compose.io 's managed postgres DB. But the database has gotten big and we have to pay $200 a month at its current size. I want to move and run these on VM's on DigitalOcean to reduce the costs and be able to scale as needed. I plan to provision 2-3 VM's with a 1 node for running a cluster mgmt software like ClusterControl and 2 VM's for the actual postgres DB's.
Looking for suggestions if this is the right approach and if there is a better cluster mgmt software that I should be looking at.
r/postgres • u/djangulo • Nov 01 '19
Hello everyone at /r/postgres.
After seeing a different post with some information get promptly called out for BS, I thought that I should subject my own writing to the same process, so as not to be posting garbage.
Below are some excerpts of an article I wrote recently, and I'd like to know the accuracy of the facts I wrote, particularly about PostgreSQL and databases, in hopes of correcting any mistakes.
If you need some context, the article itself it's about creating a Go application that uses a Postgres DB, and writing some unit and integration tests along the way. I can provide more details should you want them, but I don't want to taint this post with a self-plug.
I apologize if this is the wrong place to post this. Thank you in advance!
---
Oftentimes when creating software, it's necessary to save (or, more precisely, persist) some application state.
As an example, when you log into your online banking system, the system has to:
Check that it's really you accessing the system (this is called authentication, and is beyond the scope of this chapter).
Retrieve some information from somewhere and show it to the user (you).
Information that is stored and meant to be long-lived is said to be persisted, usually on a medium that can reliably reproduce the data stored.
Some storage systems, like the filesystem, can be effective for one-off or small amounts of storage, but they fall short for a larger application, for a number of reasons.
This is why most software applications, large and small, opt for storage systems that can provide:
Reliability: The data you want is there when you need it.
Concurrency: Imagine thousands of users accessing simultaneously.
Consistent: You expect the same inputs to produce the same results.
Durable: Data should remain there even in case of a system failure (power outage or system crash).
NOTE: The above bullet points are a rewording of the ACID principles, it's a set of properties often expressed and used in database design.
Databases are storage mediums that can provide these properties, and much much more.
There are many different types of databases, each one with its own data structures, procedures and algorithms. In this chapter we will be focusing on SQL databases, which is of the relational type, using the database/sql package and the postgres driver pq.
There is a fair bit of CLI usage in this chapter (mainly setting up the database). For the sake of simplicity we will assume that you are running ubuntu on your machine, with bash installed. In the near future, look into the appendix for installation on other systems.
RDBMS (Relational DataBase Management System) is a software program that allows users to operate on the storage engine underneath (namely, the database itself).
There are many choices and many capable systems, each one with its strenghts and weaknesses. I encourage you to do some research on the subject in case you're not familiar with the different options.
In this chapter we will be using PostgreSQL: a mature, production ready relational database that has been proven to be extremely reliable.
The reasons for this choice, include, but are not limited to:
- Postgres doesn't hold your hand.
While there are GUI tools for visual exploration, Postgres comes by default with only a CLI. This makes for a better understanding of the SQL commands itself, and also makes scripting much easier (we won't be covering database scripting in this guide).
- It's production ready
The default settings for PostgreSQL are good enough to be used in a production environment (with some caveats). Using it during development helps us close the gap between the testing, staging and production environments (also referred to as dev/prod parity. As you will soon see, this will present a challenge during development, that, when overcome, renders you entire application more reliable (hint: integration tests).
The easiest (and cleanest) way of getting PostgreSQL up and running is by using docker. This will create the database and user:
See https://hub.docker.com/_/postgres for more details on how to use this image.
~$ docker run \
-e POSTGRES_DB=bookshelf_db \ # name for the database
-e POSTGRES_USER=bookshelf_user \ # name for the database user
-e POSTGRES_PASSWORD=secret-password \ # database password
--publish 5434:5432 \ # map port 5432 on host to docker container's 5432
--detach \ # detach process
postgres:11.5 # get official postgres image, version 11.5You may need to run the above command with elevation (prepend it with sudo). If you already have PosgreSQL installed on your system, but would still want to run it with docker, you have to change the host port to a different one (syntax is "--publish HOST:CONTAINER") like --publish 5433:5432, and change your database connection string (in the application) to point to this port (5433, in this example).
Install PostgreSQL with the package manager.
~$ sudo apt-get upgrade
~$ sudo apt-get install postgresql postgresql-contribPostgreSQL installs and initializes a database called postgres, and a user also called postgres. Since this is a system-wide install, we don't want to pollute this main database with this application's tables (PostgreSQL uses these to store administrative data), so we will have to create a user and a database.
~$ sudo -i -u postgres # this will switch you to the postgres user
~$ psql
psql (11.5 (Debian 11.5-3.pgdg90+1))
Type "help" for help
postgres=# CREATE USER bookshelf_user WITH CREATEDB PASSWORD 'secret-password';
CREATE ROLE
postgres=# CREATE DATABASE bookshelf_db OWNER bookshelf_user;
CREATE DATABASEYou can view users and databases with the commands \du and \l respectively, inside the psql shell.
...
Key points
A transaction represents a batch of work that needs to be performed together. A transaction has to be started with BEGIN, and is either saved with COMMIT or all the work done so far reversed with ROLLBACK.
We don't use ROLLBACK in our migration because our simple creation of tables and index is very unlikely to fail, and it is safeguarded by the IF NOT EXISTS clause, which does nothing if the table or index already exists.
A database index is, in layman terms, a trade-off that improves the retrieval of information (if done right) by giving a little more every time data is added.
Here are more formal definitions if the subject interests you: Wikipedia, Use The Index, Luke.
In this case, the index is redundant, as PostgreSQL creates an index on the PRIMARY KEY of a table by default.
The SQL language is part of an ISO standard, and most database engines comform to it partially. This means that code written for one RDBMS (say, PostgreSQL), will cannot be interpreted as-is by a different one (say, SQLite3). There are a lot of similarities, however, and the changes required are often small.
Keep in mind that the SQL you're seeing here is very PostgreSQL specific, and some, if not all of it, may not be executable in a different engine.
...
PostgreSQL is complaining that the constraint already exists. Unfortunately, there is no handy IF NOT EXISTS for constraint creation on PostgreSQL. We have two ways to go about this:
Create a PostgreSQL function using the scripting language provided by PostgreSQL.
Drop the constraint before creation, to ensure it runs without a hitch.
Being honest here, option 2 is bad. This exposes your system to exist without the constraint, even for a few milliseconds, and bad things could happen. Not to mention the cost of the unnecessary write operation.
But, since this is not an SQL book, we're going to opt for the easier of the two, that is, option 2. If this were a real application, option 1 would be the choice without question. If you still want to go this way, search online for "postgresql add constraint if not exists", answers abound.
...
I admit that I deliberately left out an important part of the connection string, the query parameter sslmode=disable. Partly to get this error, partly to explain SSL.
Databases are generally used over networks, and, like all network connections, they should be secured if they have sensitive data. One of the security measures PostgreSQL can implements is Secure Socket Layer, or SSL. It allows encrypted connections to and from the database.
Our database lives locally, so it would be redundant to implement encryption here.
Change the connStr constant inside NewPostgreSQLStore to include the query parameter sslmode=disable.
...
If you're interested in databases and Database design, I suggest you familiarize yourself with database normalization. Below are some useful resources.
---
EDIT: markdown to fancypants switch betrayed me: added missing text.
r/postgres • u/squeezetree3021 • Sep 25 '19
r/postgres • u/mnem0 • Jul 09 '19
r/postgres • u/sdns575 • Apr 05 '19
Hey there, I'm a fan of postgres and I use it everywhere. In my last experiment I need a faster db operation and someone told me to use nosql db like mongodb for a big data on db. At the moment I have not big size data to store on db and before starting I need more knowledge.
Now after several search I discovered that also postgresql can be a nosql db. Reading on web seems that PG is 2.1 faster then mongo, and after reading bad experiences with mongodb why not use directly PG?
I'm not a guru so if I write something stupid, please don't burn me.
First question: to use postgres as nosql db I must only use JSON data type (and another type that I don't remember now) or I can use also for example a simple structured table with an array to store words of several strings of a file? In my case for example I need only to store words and not "object" so an array should be better.
Second: a nosql db mean that I must not use operation like join, so I can simple insert data like obtained and perform a query with structured data?
Third: what is the real difference between the two? I explain. I read that one great differences is about data type where a nosql can handle "any" type of data/object and on relational with normal table you can insert data only as specified on table structure. What I don't understand is how queries differ between two type. For example what differ from "select * from table where somecondition" and "select data->>word from table where condition"? In these queries results are very similar but why the second query should be faster then first.
Thanks in advance
r/postgres • u/rrrosenfeld • Nov 10 '17
r/postgres • u/RobAtticus • Oct 24 '17
r/postgres • u/dsandip • Mar 16 '17
r/postgres • u/joncrlsn • Mar 01 '16
r/postgres • u/lucianboboc • 10d ago
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/dbforge_dev • 18d ago
PostgreSQL GUI tools fall roughly into three groups: lightweight clients (TablePlus, Beekeeper Studio, Postico) and full IDEs (pgAdmin, DBeaver, dbForge Studio for PostgreSQL). Asking which one is best doesn't get you far. It's more useful to look at what each group handles well, task by task.
| Task | Lightweight clients | Full IDEs |
|---|---|---|
| Browse and edit table data | Fast to open, clean UI. Usually the best experience here | Works, with filtering, grouping and export on top |
| Writing SQL every day | Editor with basic completion | Context-aware completion, formatting, snippets, refactoring, query history |
| Query performance | You run EXPLAIN yourself | EXPLAIN Plan view plus profiling tools. In dbForge you can compare profiling runs before and after a change |
| Server admin (roles, backups, maintenance) | Limited | Varies by tool, usually not the focus |
| Comparing schemas between environments | Usually not available | Schema and data compare with reviewable sync scripts and CLI runs |
| Test data, reports, automation | Rarely | This is where IDEs pay off |
| Cost | Free tiers or low-cost licenses, check the limits | Mostly paid, but part of them offers free editions |
When a lightweight client is enough
You mostly read and edit data, your schema is managed by an ORM or a migration tool, and you rarely write long SQL by hand. On a Mac, a native client like Postico may simply feel better than anything cross-platform.
When a full IDE starts to make sense
You own the schema, you work across dev, staging and prod, and the same tasks keep coming back: checking that environments match, preparing test data, producing the same report every week. That's where completion quality, compare tools and CLI automation save real time.
A note on dbForge Studio for PostgreSQL so it's clear where it fits. It also works with PostgreSQL-compatible services like Amazon Redshift, Aurora, Azure PostgreSQL and Supabase.
Which group are you in? And if you switched from one to another, what made you switch?
r/postgres • u/BloodySouly • 23d ago
r/postgres • u/klekpl • Sep 20 '26
I’ve released the first 1.0 alpha of pgwrh, a set of PostgreSQL 18 extensions for scaling reads.
It distributes table partitions across logical replicas. Each replica stores a subset of the data and queries its peers for the rest, so applications can query the complete table from any replica. Writes go to a central controller.
Features include:
Configurable shard redundancy and placement across availability zones.
Placement previews, controlled rollouts and rollback.
pgwrh_wait, which waits for replication through a specified LSN before reading.
A browser console and Docker Compose quickstart.
I’ve worked on this for a very long time. It was only with recent advances in AI that I could finally get it into a state I felt able to release.
This is an alpha for testing. I’d love feedback on real workloads, installation, operational issues and anything that feels unnecessarily complicated.
r/postgres • u/Forsaken_Snow8355 • Aug 27 '26
I want to migrate my PostgreSQL database from AWS to an EC2 server on AWS. If anyone has done this before, could you please suggest the steps or share any blog/documentation that I can refer to?
r/postgres • u/Capital-Currency9045 • Aug 13 '26
Hi All
I’ve been working on a custom data structure and algorithm for hierarchical indexing.
while I designed the algorithm myself, I wouldn't claim to be a definitive master of hierarchy trees. I'm mainly sharing these early numbers in hopes of connecting with the right people to see if there's genuine value.
I ran benchmarks against 1M and 2M node recursive trees on PG 16. The baseline comparisons against ltree are looking solid:
Huge I/O Drop: For descendant queries, B-tree range scans touch up to 74x fewer buffer pages.
Query Speed: Subtree queries run 1.0x to 6.7x faster. Ancestor lookups (via SP-GiST) execute up to 7.3x faster.
Storage Density: A custom compact encoding shrank the on disk value size by 42.7%. This translates to a ~23% smaller B-tree index footprint.
Write Performance: Appending 50,000 leaf nodes is roughly 2x faster. Reparenting large subtrees is 1.2x to 2.7x faster
I have some thoughts where this may be beneficial but lacking some subject matter expertise when it comes to practical application of hierarchy data.
- Could it make servers run more efficiently?
- Do other more efficient extensions/algos beat these benchmarks? Is LTREE just a default?
- What kinds of large scale operations would this benefit? Domains/applications?
- What should my benchmark tests look like?
Eager to get some expert opinions and either validate my thoughts or give me some reality - cheers!
r/postgres • u/scriptedlife • Aug 11 '26
r/postgres • u/Wooden-News-962 • Aug 11 '26
Has anyone encountered subtransaction overflow in production? This was an awesome article to read but I haven't experienced it yet.
Wonder how many hairs I would have ripped out.
r/postgres • u/dani_estuary • Jul 07 '26
Hey! I'm a huge fan of Postgres and CDC in general, and after some research, I recently wrote about how this combination can empower AI Agents. I feel like Postgres CDC is underappreciated in this context, so I wanted to do what I could to spark some conversation. Let me know what ya'll think!
r/postgres • u/Able_Artisans • Jun 11 '26
Are your developers still switching between tools just to handle different databases? You’re burning time, not just money. In 2026, the gap between high-performing dev teams and the rest isn't just talent—it's the tools they’re given. And here's the kicker: only a handful of leaders understand how much efficiency is lost by juggling fragmented environments. Let’s fix that.
Whether you're overseeing a .NET department, driving innovation as a CTO, or managing risk in a regulated environment, this guide will help you choose a multi-database IDE that aligns with your business goals, security standards, and delivery timelines.
Below are the top IDEs for teams working across MySQL, MariaDB, PostgreSQL, Oracle, and SQL Server—each with real-world upsides (and the risks you should know).
1. dbForge Edge — The Strategic Powerhouse
Best for: Managers who need a unified tool that empowers multiple roles—from developers to analysts—while keeping IT governance tight.
Why it’s different: dbForge Edge isn’t just a database IDE—it’s a multi-engine productivity suite. One license, four RDBMSs: MySQL/MariaDB, PostgreSQL, Oracle, SQL Server, and a wide range of cloud services. Designed with GUI-first workflows, it enables rapid query development, schema design, performance tuning, and even real-time data visualization without switching tools or retraining staff.
Strengths:
Intuitive, unified GUI for database development
Smart code completion and refactoring
Advanced query profiling and performance tuning
Built-in reporting and visualization
Secure role-based access & audit trails for compliance
Risks:
Requires team onboarding
Lack of advanced features for DBAs.
2. DBeaver Ultimate — Open-Source Grown Up
Best for: Tech-savvy teams in smaller orgs who want a low-cost, highly customizable IDE
Strengths:
Open-source core with premium extensions
Supports a wide range of databases
Solid data editor and ER diagrams
Good for individual contributors with mixed-stack tasks
Risks:
Interface less intuitive for non-technical managers
Support is community-driven (slow for urgent bugs)
Use Case: A small SaaS team led by a hands-on CTO using PostgreSQL and MySQL might find this a lean, no-frills solution.
3. DataGrip by JetBrains — For Precision Control
Best for: Senior engineers and managers who value precision, customization, and don’t mind complexity
Strengths:
Highly advanced code intelligence
Version control integration
Customizable workflows and shortcuts
Strong for developers who also write stored procedures
Risks:
Steep learning curve for non-dev team members
Lacks some advanced GUI-based tuning features
Consider it if: Your development team is experienced, and you’re focused on highly customized backend systems.
4. Toad Edge — Lightweight SQL IDE for MySQL & PostgreSQL
Best for: Dev teams focused on open-source engines in highly controlled environments
Strengths:
Clean interface
Schema comparison and data sync
Strong change management controls
Good for small teams working in regulatory environments
Risks:
Limited to MySQL and PostgreSQL
Less frequent updates
The real question isn’t “which IDE has the most features?” It’s “which one removes the most friction for your team without creating new chaos?” If your devs are still jumping between tools for every database, that’s not flexibility. That’s workflow debt wearing a fake mustache.
r/postgres • u/ForeignsFriends • May 13 '26
Half our team is on SQL Server, the other half on PostgreSQL. We've been looking at dbForge because it covers both, but honestly the harder problem isn't the tool. SQL Server people think in SSMS. Postgres people think in pgAdmin or DataGrip, and they've been doing it that way for years.
Every time we try to standardize on something it turns into a workflow debate more than a technical one. Different habits, different expectations for the UI.
Anyone actually using dbForge across both RDMSs in the same team? Did the mixed-engine support help, or did people just end up sticking with different tools anyway?
r/postgres • u/stringray55 • Jul 01 '20
My org needs me to write a script for local setup, for that I have to write a script file which can automate few things like create few Users and some roles with a single click of button.
can anyone tell me how to do this?
r/postgres • u/Tallkotten • Jun 06 '20
I'm running a postgreSQL database on AWS and I'm looking for a quick and cost effective way to setup some monitoring on key queries.
Think "light" business intelligence. I've looked and used https://statsbot.co/ before but I'm looking for some alternatives.
What have you used before?