r/programming • • Sep 24 '20

PostgreSQL 13 Released!

https://www.postgresql.org/about/news/2077/
1.3k Upvotes

236 comments sorted by

View all comments

60

u/tomma5o Sep 24 '20 edited Sep 24 '20

Sorry FE dev here, why you guys prefer postgreSQL over mySQL?

103

u/FREEZX Sep 24 '20

I prefer Postgres for it's JSONB storage and indexing, basically allowing it to take any JSON data as a field and quickly look things up. I see it as having benefits of NoSQL databases while keeping it relational.

-13

u/blackAngel88 Sep 24 '20

What do you mean with JSONB indexing? Sure you can create index on jsonb_column->someField, but I don't think Postgres automatically indexes the json like you would expect from MongoDB on the documents..?

Postgres is awesome and the JSONB can be very useful. But it's not a 100% substitute for anything MongoDB.

6

u/mateoestoybien Sep 24 '20

You can create a GIN index on jsonb that indexes a variety of different operators. It's not perfect, but it's more than the functional index you put above. End of the day, postgres does not store statistics about sub documents in json, so you'll never get amazing performance when filtering using jsonb; it's best to use it to store data that is just along for the ride.