6 ms·
> Another classic is the “joins are slow” argument The only person I knew who died on that hill would insist on doing two queries to the database, and then wou
by sonthonax 4y ago
> Another classic is the “joins are slow” argument
The only person I knew who died on that hill would insist on doing two queries to the database, and then would insist on doing a client side cartesian join.
- lupire 4y agoTo be fair thata a reasonable approach if the database is at its monolithic scaling limit in CPU but not IO, while the clients can scale horizontally to more machines. Unlikely in practice, though.
- skyde 4y agooh so your talking about using the database as a file system and moving all the query logic in the client
- AdamN 4y agoI remember getting beers with somebody in the aughts who claimed that he saw an entire website where the url was the key and the webpage was the value in an Oracle database. Any code was SQL operations inside the value field.
- boatsie 4y agoIsn’t that effectively what a CMS is?
- brightball 4y agoI once had a coworker who dreamed of that exact setup.
- NoSorryCannot 4y agoThat's amazing!
- 10x-dev 4y agoAre joins in a 5NF database now as fast as querying a denormalized database?
- skyde 4y agothey always been faster! When you have 5NF, the database is smaller and all the row you join will be in memory in the SQL server PageCache. While when using denormalized database, your read will have to go to the disk.
- goto11 4y agoDepends. Denormalized means the database contains redundant data. If a query have to scan 10x or 100x as many rows due to redundant data, it is obviously going to be slower. But it is hard to say anything general since denormalization will make some queries faster and other queries slower.
- skyde 4y agowith good index you will not scan more rows. But each query will use a different copy of the same data instead of joining with the same copy. Storing both copy in memory take more space so you can’t cache as much in memory. I’m not talking redis or memcached but the page cache inside the sql engine.
- viraptor 4y agoMaybe I'm missing some context, but isn't that true by definition even if the db does nothing special? You either spend time sending N queries and waiting for responses, or join and use one query. Given actually matching scenarios for both, the one with less communication overhead wins.
- 10x-dev 4y agoIn a normalized database that's true, but in a denormalized database, by definition, you get a third option, which is to have tables with redundant data that can be returned in a single query (as if it were pre-joined, I suppose).