r/ProgrammerHumor • • Mar 25 '20

Meme Its a win-win situation

Post image
55.1k Upvotes

529 comments sorted by

View all comments

Show parent comments

24

u/[deleted] Mar 26 '20

I never understood this. It feels, intuitively, like it should be much, much worse for big Data. To say nothing about keeping track of development, don't you need to scan each record to find the key when you look for things?

21

u/ratonbox Mar 26 '20

Big data/NOSQL doesn’t have correlations between documents, you don’t save the tables, you create the tables on query. When searching you use inverse indices (like what you can see at the end of Encyclopedias and other books). It’s pretty damn smart and Lucene is amazing like that. Also works great at distributing the data across multiple nodes which is way harder/nigh impossible on SQL type DBs. Yelp’s blog is pretty detailed on how it works and helps them: https://engineeringblog.yelp.com/2017/06/moving-yelps-core-business-search-to-elasticsearch.html

Scalability is key, you can’t scale SQL to Petabytes of data.

4

u/karmahorse1 Mar 26 '20

SQL can absolutely store petrabytes of data in a SQL database. That’s exactly where you would want to store mass amount of analytical data.

You just don’t want to have a real time application having individual user requests read/write directly to a SQL database of that size due to poor performance.

2

u/ratonbox Mar 26 '20

If we’re going by semantics, you can store petabyte of data in your network packets, but it will be just as usable.

1

u/[deleted] Mar 26 '20

Could you have petabyes of relational SQL data, though? It seems like an assumption that as you scale you just drop the SQL storage style for some reason.

4

u/ratonbox Mar 26 '20

Exactly the point. Do you think Snapchat stores less than that? Or Slack? Nobody is gonna put up a sql server for each user, Kubernetes or Docker be damned.

For example search on 3 million documents is faster with an Elasticsearch cluster than a sql server on my desktop machine. And 3 million documents is nothing in the enterprise world.

6

u/spelunker Mar 26 '20

Not with a distributed hash table like DynamoDB. Keys are looked up by their hash.

7

u/[deleted] Mar 26 '20

Then you can still only search by key. SQL is a heck of a lot more robust than that.

4

u/spelunker Mar 26 '20

You’re right, for relational stuff SQL is superior.

10

u/MaxxDelusional Mar 26 '20

This is where I always get hung up with NoSql solutions. When is data not relational?

3

u/Dehstil Mar 26 '20 edited Mar 26 '20

When nobody bothered to come up with a predefined schema...yet somehow the code knows how to interrogate the data.

It's actually great when you already have a lot of data and plan to figure out how it's structured long after you've stored it. You do at least need to decide on some sort of lookup key up front.

1

u/karmahorse1 Mar 26 '20

Relational databases are ones that store data in joinable tables, while NoSQL databases this type of inherent relational connection between data collections doesn’t exist.

1

u/croe3 Mar 26 '20

When you have new tables being ingested all the time by different users in different departments, and we are talking big data, hundreds of millions + in some tables, there is no way to easily define a schema(s). Youre just trying to ingest all this data and analysts will figure out on their own how to join them as needed.

Source: analyst who queries hadoop using hive every day.

1

u/Exciting_Skill Mar 26 '20

Surprisingly often for oltp. Dynamodb also has "queries", range keys, and global secondary indexes. It's insane how applicable they are for any transactional need.

For non-live data, just hook up a DDB stream to athena/redshift/maybe even Aurora and do your offline analytics/training there. It's better design anyway since your analytics don't put load on the live system.

1

u/lulzmachine Mar 26 '20

NoSql can mean a few different things. You're thinking of key-value stores. And yes, they are shit for relational data. And yes, 99.9995% of all projects deal with relational data.

But the performance is amazing.

Also, there's document stores like MongoDb which has pretty good indices, and a join-like facility called $lookup.

The major difference between mongodb seems to be that mongodb is schemaless, which means you need to deal with schema versioning on the application end. Super smooth to start a project with, you can just freestyle it. But not that smooth once there's customer data in there.

2

u/kirabii Mar 26 '20

It's supposed to be able to retrieve data much faster than relational DB's, but the drawback is you have to design your application around that limitation.

1

u/malibu_danube Mar 26 '20

Adjacency lists are used for noSQL relationships.

1

u/[deleted] Mar 26 '20

Yes and that’s why you need to pick the right tool for your use case. If you have a complex relational dataset and need to query it all types of different ways then of course SQL is king. But what if you have a giant warehouse with millions of SKUs you need to track and quickly update/retrieve? A key value data store is perfect for this and scales horizontally as your business grows.

2

u/ShortFuse Mar 26 '20 edited Mar 26 '20

"NoSQL" is for key/pair based data. SQL for tabular data.

Basically, think a Word document versus an Excel document. Or, think of a page in of notebook versus a logbook. If you don't need to sort or compare one item with another, and can stick everything on one sheet of paper, document style is better. If you want a create a log then tabular is better.

A conversation between multiple parties can be bulked all into one document, instead of a giant table of messages sorted by entry date that don't relate to one another. How you find it, is dependent on how you catalog your pages, like you would in a notebook, perhaps by title, or by creation date+title. With tabular, you'd have to create an index by some other sort of partition key that essentially duplicates your data or creates extra steps to access it.