Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Joins are cheaper than the alternatives.

If you have billions of rows you need to search through for a single row, it will be costly unless you have the appropriate indexes. Storing data in JSON fields or similar is only going to make it slower.

If you are only selecting a single row, a join will be instantaneous. If you are joining many rows on either side it has a cost, but so has denormalized data since you just need to scan through that many more rows. Sure in certain specific cases denormalization can be a valid optimization, but in the general case it will just make queries slower.

Saying joins are cheap or expensive only makes sense when comparing to the alternative.



> If you are only selecting a single row, a join will be instantaneous.

Exactly. It's not like the join materializes explicitly in memory.

This has all been known for decades since the beginning of relational databases. That's why taking a DB class is valuable, or at least reading a good DB fundamentals book.


Would you care to mention such a book? In the unlikely event that I ever encounter an individual that would need it.


Database System Concepts by Silberschatz, Korth and Sudarshan is great.

I used the 5th edition, but have heard the 6th edition apparently regressed. There's now apparently a 7th edition that I can't comment on.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: