5 ms·
I once worked on a site where the original developer clearly didn't know joins existed, so if he wanted data from two related tables, he'd get all the required
by MattBearman 15y ago
I once worked on a site where the original developer clearly didn't know joins existed, so if he wanted data from two related tables, he'd get all the required results from table one, then loop through them, one by one, querying table two for the corresponding record. Sometimes this went 3 or 4 tables deep, the site would take nearly a minute to load a table of products.
- puredanger 15y agoMmmm... nested loop joins. Little more code and he would have his own database. :)
- gibybo 15y agoI see this pretty often with people who haven't spent much time with relational databases. I suppose it's understandable since thinking in sets with SQL is a different paradigm than they are used to, but I even see tons of PHP/MySQL tutorials online that use this method when they should be using a join.
- MattBearman 15y agoI think would have been understandable if he'd grabbed all the required ids from table one and done some kind of where in() with those ids on table two. But the way he did it, if table one returned 100 rows, then he'd be making 101 queries to the database. Don't think I could ever understand that :S
- flomo 15y agoIn the old days, MySQL didn't support foreign key indices, so the LAMP developer community had this mentality that "Joins are slow" or even "Joins are evil" and actively encouraged people not to use them. So its not really surprising this kind of thing is still out there - PHP tutorials are somewhat infamous for promoting 'worst practices'.
- jaylevitt 15y agoYeah, I know a Rails developer who thinks four-way joins are a design smell.
- deleted 15y ago[deleted]
- tkahn6 15y agoYep I did this at a summer job in highschool doing PHP/MySQL. One of the more senior developers saw what I was doing (after I had it working btw) and laughed and told me about joins. So I went to lunch and came back and learned about joins and replaced 50 lines with 5.
- forinti 15y agoI've seen this in an Access application. I've also noticed a strange character that constantly shows up: the accountant that has acquired a taste for programming. Luckily, there never seems to be more than one per institution.
- caf 15y agoI think Accenture is the corporate instantiation of that character.