DEV Community

What database do you use?

zchtodd on October 09, 2019

I'm curious what databases people are using for their projects, and why you might have decided on that. I'll list some of the databases I've used ...
Collapse
 
rhymes profile image
rhymes

I've been using PostgreSQL for a long time and it honestly hasn't disappointed me.

Usually when I had slow queries the problem was the query itself (including indexes on the columns) or the server load. To be honest I rarely found bugs that affected the outcome of a query or skyrocketed the execution time.

Are you having problems with the output of EXPLAIN ANALYZE ?

Also: since the introduction of JSONB in PostgreSQL there's a lot of stuff you can get away with it without having to introduce a second DB in your stack.

Collapse
 
zchtodd profile image
zchtodd

PostgreSQL is probably my favorite database too, and I totally agree, it's almost always my crappy queries that are to blame!

The case I talked about in the post was really interesting though, because the query planner was producing radically different plans, all depending on how "fresh" its table stats were.

I learned that table stats are automatically refreshed on a commit, but my slow query was running inside the same transaction, after a huge insert. So the insert skewed the table data in a way that the stats didn't reflect, therefore producing a bad plan.

The ANALYZE command (which is different than EXPLAIN ANALYZE), when executed against a table, tells PG to sample the table contents and refresh its statistics.

Collapse
 
bradtaniguchi profile image
Brad • Edited

With my personal projects I always go with Mongodb for the simple reason that there are free tier hosting solutions out there (Yes I am that cheap).

At work I'd go with what is in the requirements or whatever is supported with the cloud provider we have to build on.

Collapse
 
lawjeremy profile image
Jeremy Law

PostgreSQL if I need a relational db, Mongo if I don't.

Collapse
 
zchtodd profile image
zchtodd

I'm curious about what Mongo offers in those situations, because I've never used it, and I think my first instinct is to just use PG no matter what. (And I don't mean that in any kind of flame-bait way, I've just never used it.)

Collapse
 
lawjeremy profile image
Jeremy Law

For me it's personal preference. I work mostly with Javascript, so Mongos query syntax and JSON like document structure feel familiar.

Collapse
 
avalander profile image
Avalander

Same.

Collapse
 
m3lles profile image
Marvin Trilles

mssql at my 9-5 work, mongo and mysql for all others :)

Collapse
 
zchtodd profile image
zchtodd

I've never used MS SQL myself. One really random feature that I wish Postgres had, that MS SQL actually has, is "temporal tables". You can basically write a query and say "as of" a certain time, and the results will reflect what was in the database as of that time.

System time in SQL Server

Collapse
 
m3lles profile image
Marvin Trilles

your comment regarding temporal tables gave me an idea how to solve my issue at work 💡. thanks!

Collapse
 
hte305 profile image
Ha Tuan Em

Mongo and MSSQL.

Collapse
 
mr_technologytz profile image
Kitwange jr

Hellow Sir , do you have any experience with php framework