News for hackers. Stuff that matters.
Re:Mongo but on Postgres and with strong consistency benefits by winternewt on Monday July 08, 2024 @04:04AM (#40903486)
If you have schema requirements, why _not_ do it with tables and columns instead? The point of the jsonb column would be precisely to store arbitrary stuff that has no schema.
Re:Mongo but on Postgres and with strong consistency benefits by bruce343434 on Monday July 08, 2024 @05:25AM (#40903917)
I usually see this (dynamic scripting langs, schemaless databases) play out as a very good environment to prototype in, very few barriers to change things or make stuff up as you go. Then the prototype is not discarded but "iterated" to form the actual production code. The (now needlessly so) flexible JSON store is grand-fathered in.

I have yet to come across an actual use case for JSON stores in a production app with an established design. What the hell do you mean you have no idea what the data might hold?? Why are you storing unknown, undefined, undefinable things??? Or perhaps, there actually is a schema i.e. fields we rely on being present, but we were too lazy to define it formally?

Re:Mongo but on Postgres and with strong consistency benefits by SSLy on Monday July 08, 2024 @08:13AM (#40904687)
We're evaluating solutions to ingest business app events and infrastructure logs. Document-ish JSON-ish "DB"/search engine seems like best solution, because no one does structured logs properly.

Now we have to pick the stack. ELK, Loki + Graphana, Graylog or maybe just dump into MongoDB?

Re:Mongo but on Postgres and with strong consistency benefits by okr on Monday July 08, 2024 @07:30AM (#40904443)
Customers sent custom things.
Re:Mongo but on Postgres and with strong consistency benefits by mexicocitinluez on Monday July 08, 2024 @08:54AM (#40904994)
> I have yet to come across an actual use case for JSON stores in a production app with an established design

Healthcare. Clinical data is unstructured and constantly changing. Would you build out a table with 2000 columns that changed yearly? What about 5000?

Re:Mongo but on Postgres and with strong consistency benefits by eropple on Monday July 08, 2024 @09:36AM (#40905310)
Well, there are a decent number of those use cases, but the one I find most compelling is storing an exact record of what another service sent me in case I need it later. I pull out and store in my typed schema the relevant bits of, say, an OpenID Connect response, but I'll often store the entire response as well in case I want to add functionality in the future based on additional fields, etc. in that response and roll forward without having to have an intermediate state.
Re:Mongo but on Postgres and with strong consistency benefits by tracker1 on Monday July 08, 2024 @10:43AM (#40905882)
Adjacent data that is very alike for most usage but different in subtle ways.

Classified ads, the additional details for a Car are different than a Shirt, but both would be ads. And adding a nearly infinite number of fields or a flexible system in a set of schema or detail tables is significantly worse than unstructured JSON.

Another would be records from different, but related systems. Such as the transaction details for an order payment. Paypal data will be different from your CC processor, or debit transaction, but you can just store it as additional details for a given "payment" record.

Another still would be in healthcare, or any number of other systems where the structures will be different from one system to another depending on data interchange, where in the storage you don't care too much, only in the application layer will it make any necessary difference.

Re:Mongo but on Postgres and with strong consistency benefits by goosejuice on Monday July 08, 2024 @11:00AM (#40906036)
Data owned by another service/application/org that is written and read without modification.

For example, a healthcare document that wasn't built or technically owned by the application storing it.

For example, a web text editor that serializes it's state as json.

Not json, but a web scraper storing html documents.

These have structure, it's only that the structure is built/maintained outside of the application storing it. You could of course transform it but I think it's a bit obvious where that might not be worth the cost/complexity.

Re:Mongo but on Postgres and with strong consistency benefits by cryptonector on Monday July 08, 2024 @12:38PM (#40906899)
You can always change the source of truth so instead of being the JSON texts it's the properly normalized schema and then you can have a VIEW that returns JSON for apps that need JSON. And if need be you can denormalize a bit and have a JSONB column that stores the document as the serialization of the rows' other columns.

That's what's really nice about SQL: you can perform these sorts of schema surgeries and still retain backwards-compatibility using VIEWs.

Re:Mongo but on Postgres and with strong consistency benefits by cruffle_duffle on Monday July 08, 2024 @01:14PM (#40907233)
A use case for me is I’m calling a lot of different 3rd party APIs that return similar things but in widely different data structures with a lot of information specific to that site. I take what is standard across all the API’s and store that in my relational database but anything I didn’t use I store in a JSONB field just in case I need it some time in the future.

In other words I’m not really using anything in that JSONB field… at least right now.

Re:Mongo but on Postgres and with strong consistency benefits by marcus_holmes on Monday July 08, 2024 @05:40AM (#40903981)
I think my learning was "all data has schema, eventually"

We thought it was just a bunch of data documents. But it turned out that to actually use that data in an application it had to have predictability, we had to know certain fields were present and in a fixed format. You know: a schema.

Re:Mongo but on Postgres and with strong consistency benefits by mexicocitinluez on Monday July 08, 2024 @08:59AM (#40905041)
I'm confused about this. Since when can't you enforce a schema on a document you're storing? Did you have no way to change the data before it hit the database?

NoSql stores still have schemas.