News for hackers. Stuff that matters.
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by dheera on Thursday March 11, 2021 @02:46AM (#26421407)
When you get piles of JSON data from somewhere else (e.g. an API response from a provider you subscribe to) and want to store all of it intact, query it, and that somewhere else may insert new fields at any time in the future without telling you.

When you have multiple types of objects with differently populated fields that you want to store in a single collection and query across them in currently unknown ways, and where you need flexibility for the unknown.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by drodgers on Thursday March 11, 2021 @02:51AM (#26421441)
That sounds like a great use case for OLAP and fuzzy search solutions.

Eg. Dump all of the data to S3 and search it in parallel via AWS Athena.

If you want fast fuzzy search, then elasticsearch is built for this.

If the data is small enough that you want B-tree indexes (with the accompanying slower writes and lower query latencies), then any SQL database with a JSON column will work.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by dheera on Thursday March 11, 2021 @02:55AM (#26421466)
> Eg. Dump all of the data to S3 and search it in parallel via AWS Athena.

Too proprietary. Can't be run locally, on robots, etc. Can't be transferred to other cloud providers. Also S3 is horribly slow to write or delete thousands of records at once.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by kornish on Thursday March 11, 2021 @03:36AM (#26421700)
> Too proprietary.

Every major cloud provider has a blob store. Most are S3-interface compatible, or can be fronted by something which is, like Minio.

> Can't be run locally, on robots, etc.

If the contents of your S3 keys are just line-delineated JSON files, you can easily download those files and run scripts or process them locally.

> Can't be transferred to other cloud providers.

Again, not true — a tool like rclone handles this case in a single command. Depends on the amount of data, but if anything it's easier to move a bunch of flat files between providers than copying a database backup around. You have to pay for egress bandwidth, though, of course.

> Also S3 is horribly slow to write or delete thousands of records at once.

If you're keeping one JSON record per S3 key, that is a blatant misuse of the tool and performance will be terrible. On the other hand, if you batch records into files of appropriate sizes, it's very cost-effective to store and query via Athena, Spark on EMR, etc.

If you need individual record-level access as identifiable by a key, then you'd probably be better off with Redis or Memcached. (though, those will not be as good for bulk offline processing) It's all about your access patterns.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by dheera on Thursday March 11, 2021 @11:23AM (#26425713)
> On the other hand, if you batch records into files of appropriate sizes

Too much work. If you're a startup that's too much stuff to maintain. Much easier to get a hosted MongoDB and launch tomorrow.

And when you only have 2 months rent in the bank and investors want demo after demo in order to give you cash, tools like MongoDB do make a difference. And yes, I've been in that situation before.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by dolni on Thursday March 11, 2021 @11:48AM (#26426062)
Your ability to turn the smallest of technical hurdles into an insurmountable problem is truly impressive.
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by WJW on Thursday March 11, 2021 @06:55AM (#26423076)
> Also S3 is horribly slow to write or delete thousands of records at once.

I'll add that S3 is only slow to delete things sequentially. You can delete or write an effectively infinite amount of items in parallel.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by saturn_vk on Thursday March 11, 2021 @05:12AM (#26422334)
That's what I'm using postgresql for, among other things. The only drawback I've ran into so far is that it sometimes doesn't pick the proper index for a specific query.
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by mschuster91 on Thursday March 11, 2021 @06:23AM (#26422846)
> and that somewhere else may insert new fields at any time in the future without telling you.

That's what interface contracts and API versioning is for - and new fields shouldn't be any problem at all unless you're parsing the JSON by hand.