Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
bryceleo1978yThere's a chance you could be wrong but I'm thinking you're right. They may just not understand joins and want something they feel comfortable supporting in case you leave the company. Lots of variables to consider in this one.
-
Joins can be "expensive", but in your case it's much better than that nested loop. Especially if the tables are indexed correctly. So, sorry to hear that ignorance from your boss and colleagues :(
-
surgiie15258y@bryceleo well I can see if it was multiple videos per product then id say the join query would be wrong and would need modified but its only one video per product. But Idk I just work here and do what I'm told lol. Its "just stick to what works and don't worry about making things great"around here.
-
surgiie15258y@SleepyOne yeah the database is a god damn shit show. They don't take advantage of fk's so they just redefine columns in other tables instead of using the relationship, they dont add constraints or index columns. Its pretty bad around here:/ I'm just dealing with it and do what I'm told until can find another job but job hunt has been unsuccessful so far:(
-
burtybob4488yJoins are better in this situation I'd say as it's easier on the DB to deal with that than a lot of queries...
-
It depends.
Generally speaking, the sentence "sql joins are bad" means nothing and I would gladly burn alive someone who tells me so ;) nah, joking!
In this particular case, if I understood the situation well enough, the join is perfectly fine.
Otherwise, I would have gone for a 1:n relationship (1 product: n videos) and a table dedicated exclusively to videos. Beware, I may be wrong, it depends. -
sha-i2068yI'm fairly certain your coworkers are wrong and their design is extremely unscalable...I saw a situation like this at my work, some code was fetching a list of object IDs, and then fetched the objects one by one. Ruined performance during load testing.
Related Rants
Are sql joins a bad practice? :o
I recently did some work on a page for a site ive never worked on cause my boss told me to. So they recently added product detail video urls to a table that has a relationship to the products table. The existing code was querying for the products on that said page and then during the loop that was outputting the products ,there was another query for getting the url for the current iteration/product. Told my coworker that this imo was pretty inefficient way to do it and switched it to a join and did 1 query then output that but his words were "The way it is now maybe ineffecient in your opinion but it works. Also combining inner joins with left or right is not a good practice. If the data is changed upstream the entire query would need to be redone to accommodate the change". Mind you that they query views a lot which are all made from queries that use joins and I'm also pretty sure these views were written by someone who used to be here because these guys are not good at sql or at least that's what there queries show. I'm at the point now where I'm realizing that my boss and this other guy don't give a fuck about efficiency or doing things the right way they just want it "to work". So this coworker changed my query back to the way it was because he said it broke the shopping cart even though that was already broken when I started... What is life? Maybe I'm the stupid one?
undefined
sql
sql joins
amiwrong