3 ms·
Avoid SQL joins in your website code Disagree. If you need to join data, you have do do it somewhere. You think you are going to do a better job of it than t
by ams6110 13y ago
Avoid SQL joins in your website code
Disagree. If you need to join data, you have do do it somewhere. You think you are going to do a better job of it than the database engine, which has probably been optimized for years if not decades to do this very thing?
- ColinWright 13y agoI read it this way ... The lesson is that if you find yourself doing joins, then you need to consider whether the database should be redisgned. A join is sometimes necessary, and the engine is the right place to do it if it must be done, but it's a warning. So if possible, design your DB to avoid joins.
- argv_empty 13y agoThis response is more amusing in light of the author's first claim.
- RogerL 13y agoThe idea is to pay during write, at about any cost, to avoid paying during read. Of course that does not fit all usage cases, so the advise has to be taken with a huge grain of salt.
- toast0 13y agoIt depends on the join. If you can denormalize your schema so there's no joining, that's great. If you can change the product so there's no joining, great. If the schema and database are designed to do the join you're going to do, that's probably fine. If not, it's cheaper and easier to add capacity to the pool of shared nothing web machines than to add capacity to the pool of databases machines, so grab the data and run the join on the webserver. (or at least benchmark it; you may be surprised)