News for hackers. Stuff that matters.
Re:MongoDB shares jump more than 30% in $192M IPO by blauditore on Thursday October 19, 2017 @04:28PM (#15511281)
I know there's quite some aversion to NoSQL around here, and generally I don't care much as I'm seldomly dealing directly with databases.

But recently, I've been exposed to a fairly big and complex SQL one with several references between entities and lots, lots of X_has_Y tables. This makes me think that with growing complexity (which seems to be a general trend), NoSQL databases seem more practical at some point, or at least something less rigid than classic relational ones. I'm not saying SQL is obsolete, but it seems like its domain of usefulness is shrinking.

Re:MongoDB shares jump more than 30% in $192M IPO by mi100hael on Thursday October 19, 2017 @04:33PM (#15511328)
I'd argue the opposite is true. NoSQL requires you to be more intentional with your schema design since you can only query keys. As a database grows with complexity, you can find yourself in a world of pain with NoSQL if you all of a sudden need to query something in a different manner. At least with SQL you have more options with WHERE clauses & indexes even if performance might not be top notch.
Re:MongoDB shares jump more than 30% in $192M IPO by HodGreeley on Thursday October 19, 2017 @06:15PM (#15512008)
Not sure of others, but not true with Couchbase. You have queries just as flexible as with SQL.
Re:MongoDB shares jump more than 30% in $192M IPO by philliphaydon on Thursday October 19, 2017 @09:56PM (#15513033)
One of the reasons I love PostgreSQLs jsonb type is you get the power of relational database and power of (nosql?) Document database at the same time. i haven’t run into any query I couldn’t write against a jsonb doc. Granted dot notation on json would be nicer than ‘prop’ > ‘prop’ > ‘prop’, but I don’t feel limited.
Re:MongoDB shares jump more than 30% in $192M IPO by parasubvert on Thursday October 19, 2017 @06:03PM (#15511922)
The point is that the relational model is a fully general purpose mathematical model for managing data with integrity and with ad hock access.

Most other models are for high performance of specific access paths and punt integrity management to code, which is a throwback to the 70s. They’re glorified file systems and data structure caches. Mongo has a reputation for losing your data.

There are cases where scale and availability kills you and you need something like Cassandra or whatnot. But there are few as flexible and general as Oracle or Postgres.

Re:MongoDB shares jump more than 30% in $192M IPO by andrewmutz on Thursday October 19, 2017 @04:41PM (#15511371)
I don't think the HN community is averse to NoSQL solutions, but is averse to MongoDB in particular.
Re:MongoDB shares jump more than 30% in $192M IPO by erik14th on Thursday October 19, 2017 @04:55PM (#15511472)
Everyone here seems to love Postgres and hate on Mongo, I have no technical knowledge to compare the two, so IMO a lot of that love and hate is more towards the "project attitude", MongoDB is a suit, a sellout, with bullshit marketing and all Postgres is like some roots hippie, that cares a lot more about technical values and neglects marketing.
Re:MongoDB shares jump more than 30% in $192M IPO by acdha on Thursday October 19, 2017 @05:03PM (#15511545)
I think most of it was a reaction to the massive marketing push Mongo made. There were so many years of people hyping it as the answer to all of your data storage needs, followed by accounts of users hitting bugs or reimplementing most of a SQL database in code, and the promised performance benefits either didn't materialize or hadn't been necessary in the first place (“web scale” turned out to mean only dozens to hundreds of requests per second for many apps).

Meanwhile, Postgres was quietly plugging away adding new features and continuing to deliver solid performance for a wider range of workloads, including better performance on JSON document storage.

Re:MongoDB shares jump more than 30% in $192M IPO by paulmd on Thursday October 19, 2017 @05:58PM (#15511885)
MongoDB accrued a lot of bad-will due to some extremely questionable defaults, which remain defaults to this day. There's no question that you can write a fast database when there's no guarantee that data ever hits the disk, but developers tend not to like it when a database accepts their write and then silently loses data. It's also great for toy problems and 15-minute-demos... but then you inevitably run into its limitations and end up re-implementing a database in your app.

Even at its best, there is essentially no reason to choose MongoDB over Postgres with JSONB-type columns. They are essentially the same data model but Postgres gives you better guarantees of data consistency, plus a forward migration path to relational data when the day inevitably arrives when you need to model relationships between entities.

At this point Postgres is where most open-source RDBMS development work is concentrated. It's not only a solid codebase, it's piling up features pretty quickly and there are relatively few niches it doesn't fill at least adequately. All of these niches are covered by some commercial products built on top of Postgres (eg EnterpriseDB or CitusDB). It's pretty much a one-stop shop for application development. You can use it for everything from GIS to machine learning [0] pretty efficiently, and it pretty much will just do the right thing without you watching.

NoSQL really fits best around the margins, like as an auxiliary system for analytics. There is really almost no use-case where "user inputs data and we lose it" is an acceptable application behavior, so consistency is a business requirement for your master database whether you realize it or not. And consistency across a distributed system is hard so it almost always makes sense to sidestep clustering until the last possible moment. Buying more machine is cheap, replication/failover is a lot easier than consistency between distributed masters, and if you are really up against the wall there are those commercial products that can do this with Postgres.

If you want to make an analogy... Oracle is the suit, Postgres is the hardworking small business that is slowly but surely eating up Oracle's lunch, and MongoDB is a trustafarian with a hot-dog detector app. And that's why there's a lot of resentment towards MongoDB.

[0]: The 9.x series and 10.0 release have been absolutely jam-packed with new features, it's absurd how fast development is moving at the moment. One of my favorites... indexed cube queries. A cube is a data-cube type, an N-dimensional cube of data. One feature of this is distance queries, which have obvious applications in pattern recognition tasks (eg k-nearest-neighbor). One of the features in 9.6 is index functionality for these, so you can now do indexed KNN searches on your data...

https://www.depesz.com/2016/01/10/waiting-for-9-6-cube-exten...

Re:MongoDB shares jump more than 30% in $192M IPO by porker on Thursday October 19, 2017 @06:49PM (#15512206)
> NoSQL really fits best around the margins, like as an auxiliary system for analytics.

I'd say it also fits well in two niches: document datastores (so long as there's some JOIN support, via referencing nested documents vs direct nesting) and graph stores.

I remember 10+ years ago working on storing nested sets in the RDBMS and it wasn't pretty. And the RDBMS schema for Magento 1, with key-value tables all over the place which NoSQL would have removed the need for.

Re:MongoDB shares jump more than 30% in $192M IPO by paulmd on Friday October 20, 2017 @02:42AM (#15513925)
Can you define what "nested sets" means more specifically?

Postgres supports hierarchical/nested structures using the "ltree" column type. There is nothing stopping you from defining a primary key of (eg) "set1.set10.set100". There is also support for recursive views/etc to operate on these kinds of sets.

Again, if you have some kind of "sparse" column, it can make sense to put that into a JSONB column. This is effectively the same thing as attaching an unstructured document to a record for this use-case.

Re:MongoDB shares jump more than 30% in $192M IPO by porker on Friday October 20, 2017 @03:49AM (#15514167)
Sure: http://mikehillyer.com/articles/managing-hierarchical-data-i...

Joe Celko popularised them. I've been unable to find when they were first introduced; but a search of my source code archive points to having written one ~14 years ago.

Re:MongoDB shares jump more than 30% in $192M IPO by orf on Thursday October 19, 2017 @08:46PM (#15512763)
> so long as there's some JOIN support, via referencing nested documents vs direct nesting)

Which has its own problems. PG does this just fine, with a full battle-tested relational system to back it (and you) up.

> with key-value tables all over the place which NoSQL would have removed the need for.

Product X having a stupid schema is not a good basis for an argument for or against a particular product.

Re:MongoDB shares jump more than 30% in $192M IPO by porker on Friday October 20, 2017 @03:54AM (#15514194)
> Product X having a stupid schema is not a good basis for an argument for or against a particular product.

What other way could Magento have implemented user-defined columns at the time, using a RDBMS? In 2009 when MongoDB was released, JSON columnstores were something to dream of and the alternative was storing serialised data in a BLOB field. That "stupid schema" did not have an alternative I can think of, except NoSQL.

Re:MongoDB shares jump more than 30% in $192M IPO by VintageCool on Saturday October 21, 2017 @01:44PM (#15522690)
I'm not sure if those were questionable defaults, or questionable design decisions which were the only option at the time, and now persist as questionable defaults.

I'm pretty sure that mmap was the only storage engine available for MongoDB for most of the hype period.

Re:MongoDB shares jump more than 30% in $192M IPO by autokad on Thursday October 19, 2017 @05:06PM (#15511562)
i got downvoted in another thread for saying nosql has a lot of advantages in reducing work like not having to worry about carefully creating indexes when joining billion row tables. someone replied you dont need indexes. i replied I dont know how you plan on running joins on billion row tables in postgress without indexes. got downvoted again.

I bet they are still waiting for that join....

Re:MongoDB shares jump more than 30% in $192M IPO by parasubvert on Thursday October 19, 2017 @06:01PM (#15511900)
Whether you need indexes really depends on what you’re trying to do. Full table scans are more efficient if you are doing analytics on most of those rows in a time series. If you need 1 row in a billion, yes, you need an index.
Re:MongoDB shares jump more than 30% in $192M IPO by autokad on Thursday October 19, 2017 @09:55PM (#15513031)
if your doing a join on two size N tables, your O(n) cost for each record is N, thus you are doing N^2 lookups. basically reading the entire DB into memory each record.
Re:MongoDB shares jump more than 30% in $192M IPO by parasubvert on Sunday October 22, 2017 @06:01PM (#15529200)
No. Worst case a nested join of two tables M and N would be O(MN). But most real databases would have a merge or hash join which could bring this down to O(M+N) if the tables are already stored in a sorted indexed order. It is also rare the cardinality of these databases will be similar in an analytical query - usually you have one time series “fact table” and a bunch of dimensions to enrich that data.

If I’m doing analytics on a time series this gets even better with partition pruning and hash joins or bitmap indexes. And if I have a columnar database, that blows up this whole complexity argument.

My point is that, layout and indexes should never be assumed to be one size fits all. Keep in mind if I’m doing analytics I want to bring my time series data into memory at least as a stream, as I need to calculate / filter / transform the records. Not everything is about rendering a page on a website.

Re:MongoDB shares jump more than 30% in $192M IPO by acdha on Thursday October 19, 2017 @09:42PM (#15512978)
From the sounds of it, you were downvoted for not recognizing this as a textbook scenario with decades of practice and engine improvements devoted to allowing you to balance query performance against your server budget.

Interestingly enough, many of those techniques are common in the NoSQL world as well — a billion records is enough to require thinking about data flow anywhere — but the difference is that you have to deploy them more frequently.

Re:MongoDB shares jump more than 30% in $192M IPO by orf on Thursday October 19, 2017 @08:47PM (#15512772)
If you're dealing with billion row tables and using mongodb you are way out of your league. Good luck.
Re:MongoDB shares jump more than 30% in $192M IPO by autokad on Thursday October 19, 2017 @09:48PM (#15513007)
mongodb is not the only nosql db :) I use hive/hbase
Re:MongoDB shares jump more than 30% in $192M IPO by matwood on Thursday October 19, 2017 @05:30PM (#15511704)
> less rigid than classic relational ones

Less rigid than what? The schema is going to exist somewhere...

Re:MongoDB shares jump more than 30% in $192M IPO by nwatson on Thursday October 19, 2017 @05:30PM (#15511706)
So you gonna do all those JOINs in code???
Re:MongoDB shares jump more than 30% in $192M IPO by HodGreeley on Thursday October 19, 2017 @06:19PM (#15512035)
Part of the point is you don't need so many joins.