4 ms·
+1 joins are efficiently done by databases, not by applications. At least in any reasonable dataset. Joining in application works for a few thousand records.
by Xorlev 13y ago
+1 joins are efficiently done by databases, not by applications. At least in any reasonable dataset.
Joining in application works for a few thousand records.
- pkolaczk 13y agoDepends on what you are joining. Selecting five rows from one (sharded) table and the looking up matching five rows from another (sharded) table by primary key is almost just as fast from the application as it would be done by the database itself. Additionally many NoSQL databases let you store arbitrary number of data in a row, so you don't need (big) intermediate join tables. However, I agree that a database can be much faster when you want to join two huge datasets, because then it has all the fancy ways of fast joining with sort-merge-join or hash-join, etc. But if you need to join huge datasets, you're screwed anyway, because such joins don't scale at all, and are still really, really slow - they need to do at least one sequential scan (and typically 3) over each full dataset. Definitely not something you want to do in your OLTP app. I saw an OLTP app where joining a few thousand rows (yeah, thousand, not million!) killed the app performance totally, up to the point that a single user using the app had to wait >10 seconds for a page refresh. The app was probably done by someone thinking that joins are free.