Why I Usually Choose PostgreSQL for My Projects
When I start a new project that needs a database, I usually don’t spend a ton of time deciding which database I’m going to use.
Most of the time, I just reach for PostgreSQL.
It’s not because PostgreSQL is automatically the best database for every possible project. It’s simply become one of those tools that I know, trust, and can get running quickly.
I Used to Be a MySQL Guy
For a long time, MySQL was my go-to database.
And if I was working on something web-based, there was a pretty good chance phpMyAdmin was sitting there right next to it.
Honestly, that combination worked great for me for years. phpMyAdmin made it incredibly easy to jump into a database, create tables, modify data, run queries, and generally see what was going on without having to live entirely inside a terminal.
But over time I started using PostgreSQL more and more.
Eventually I realized something:
I wasn’t really reaching for MySQL anymore.
Postgres just seemed to fit better with the way I was building and deploying applications.
Postgres Just Does What I Need
Most of the applications I build need fairly traditional relational data.
Users, settings, transactions, game data, statistics, configuration, relationships between different pieces of data—you get the idea.
Postgres handles all of that extremely well.
I get a powerful relational database, great SQL support, transactions, constraints, indexes, JSON support, and plenty of room to grow if the project becomes larger than I originally expected.
For most of my projects, there’s rarely a moment where I think:
“Man, I really wish Postgres could do this.”
It usually can.
Docker Really Sealed the Deal
This is probably one of the biggest reasons PostgreSQL became my default.
I’ve increasingly started putting applications into Docker containers, and Postgres is just ridiculously easy to include alongside them.
Need a database?
Add PostgreSQL to the Docker Compose file.
Create a volume.
Set a username, password, and database name.
Give the application its connection string.
Done.
I don’t have to install PostgreSQL directly on the server. I don’t have to worry nearly as much about what is already installed on that machine. And if I move the application somewhere else later, I can bring essentially the same setup with me.
I recently wrote about exactly why I’ve become such a fan of doing this in Why Making Your App a Docker Container Can Be Incredibly Useful.
Postgres fits into that philosophy perfectly.
My application can have its container. PostgreSQL can have its container. The database data lives in a persistent volume, and Docker Compose ties everything together.
Compared to some of my older setups with MySQL and phpMyAdmin installed and configured on the actual machine, this just feels simpler and cleaner.
It’s Free and It’s Everywhere
PostgreSQL is open source, mature, extremely well supported, and available basically everywhere.
Whether I’m running something on my own server, inside Docker, in AWS, Azure, or somewhere else, finding a way to run PostgreSQL isn’t exactly difficult.
There’s also an enormous amount of documentation and community knowledge available when something inevitably goes wrong.
That’s important to me.
I don’t necessarily want the most exciting database technology.
Sometimes I just want the boring technology that I know is going to work.
And PostgreSQL has become that for me.
Could I Use Something Else?
Absolutely.
I don’t have anything against MySQL. I used it for years, and it still works perfectly well.
SQLite is fantastic for smaller applications. SQL Server obviously has its place. NoSQL databases like MongoDB can make sense depending on what you’re building.
There are plenty of choices.
But when I’m starting a new project and there isn’t a specific reason to choose something else?
I’m probably spinning up a Postgres container.
It’s familiar, powerful, easy to deploy, and does pretty much everything I need.
And sometimes that’s really all I want from a technology.
What Do You Use?
This is one where I’m genuinely curious what other developers prefer.
What’s your default database when you’re starting a new project?
PostgreSQL? MySQL? SQL Server? SQLite? MongoDB? Something I’ve completely overlooked?
And if you’ve switched from one database to another over the years, what made you switch?
Drop a comment below. I’d love to hear what everyone else is using and why.