why are databases needed when a hash map has O(1) access and O(1) insertion and you can write queries as hand-optimized C Posted on May 22, 2023 by Anonymous why are databases needed when a hash map has O(1) access and O(1) insertion and you can write queries as hand-optimized C
How do hashmaps enforce constraints, and provide ACID transactions to multiple connections?
Try working on non-toy projects.
I maintain an React app and the database is a persistent immutable map
Did you try to store 1TB of data in your hashmap? Or ever use an index or any kind of join?
People who NEED a 1 TB hashmap don't come to this place. There might be people where who use 1 TB hashmaps, but that is because they do something wrong.
We make shaky measurers, they shake and we log the shakiness. It fills takes space to keep all those shakes
No matter how much modern girls thot it up, the simple schoolgirl outfit with cute panties look will always be the hottest
Also OP, how do you intend to efficiently query data
What does the O in O(__) mean anon?
Is it best case, average case or worst case?
Can there be situations where O(n^n) is faster than O(1)?
In the case of hashmaps it would be "expected". Best case is never interesting. Worst case is interesting, but not as interesting as average, unless you're dealing with real-time constraints.
>best case is never interesting
if an algorithms best-case meets my input data for one reason or another, then the best case is always the case. Best case is interesting in special circumstances. This isn't speculation, I've had this happen.
Databases support more operations, like range queries, that hash maps can't perform efficiently.
>why are databases needed when a hash map...
Gonna stop you right there. Is a hash map persistent? No it fucking isn't. It's a data structure. Ah, you might say, but what if we made a persistent hash map? That's called a key value store. It's a type of database. You absolute fucknut. Also, hash maps aren't strictly O(1) access and insertion. They're O(1) amortized. Sometimes you end up with a bunch of keys that have the same hash value. Then you're either not getting O(1) access or you have to rehash. And rehashing is a NOT FUCKING O(1) insertion operation. So you're fucking wrong on hash tables being the perfect for everything data structure. They're good for a lot of things, which is why a lot of databases use them, but they're also not the only data structures being used by a lot of databases.
why are you malding?
Why are you wrong?
>Sometimes you end up with a bunch of keys that have the same hash value
skill issue, use a better hash function
Why do you need a web browser when you have curl and your brain to figure out what the java script does
I can see their panties hehehehehe
instead of being mean to you, i'll simply say that most databases handle many concurrent connections and scale across multiple nodes.
now of course, redis can also do this while also all being entirely in memory with relatively decent consistency guarantees too. but you are more than welcome to write your own multithreaded scalable c application with several thousands of dollars of RAM 🙂
now do it at scale
ah, gotta love sophomores and their know-it-all spirit after their first data structures course.
Yup, that's a SNIFF from me.