114

Bob?
Yeah?
Bob, could you hand me that paperclip?
Sure mate!
Thanks.

Oh... Bob?
Uhhh... yeah?
Could you also hand me that paperclip?
Right... sure, of course.
Thanks.

Bob?
What?
Could you also hand me the next paperclip?
Fuck off, why don't I just give you the whole fucking box!

Yeah Bob, please, throw the whole fucking box.

Wait, is that a printed screenshot of my code you're attaching the paperclips to?

It sure is, Bob.

Comments
  • 13
    Hahah this has a great Fargo vibe to it
  • 17
    this is top secure, ultra fast code. Please don't make fun of it :3
  • 9
    Hilarious 😅
    Have a ++!
  • 1
    This deserves to be #1
  • 4
    Trying to find the joke 🤔
  • 1
    This really made me lol 😂
  • 2
    Looks like eloquent in blade :p
  • 0
    @lotd Yup.

    @deepmind The problem is that using a query in a loop causes a lot of queries. It's like asking the database for the first user, then the second, etc... instead of just asking it for all required users at once.
  • 1
    @bittersweet oh then it is hilarious 😂
  • 0
    It's just like turning 360° right when you need 90° left. While jumping on one leg.
  • 0
  • 0
    @wolt yeah lol
  • 0
    Okay, think there's something to learn for me, how would a statement look like if you have to query the database for all user ids in the array? Only thing I can think of is exactly this solution :/ Help is appreciated
  • 1
    @wolt Thanks for the Answer, I think what you mean is joining(?). I already did some research and I think they mean something like "WHERE id IN (1,50,30)" I didn't knew/forgot that mysql can do this, of course you can join the name etc. than too.
  • 0
    @Bitwise While I agree, with PHP backend development you can generally forget about language optimizations.

    90% of both execution time and memory usage will be the overly generic ORM bashing against the database, 9% is framework bootstrapping & request middlewares... 1% is about the way you handle loops, objects, arrays and collections.

    ORMs like Eloquent (and Doctrine to a lesser degree) love utilizing/abusing memory. They instantiate objects by the thousands, and keep everything laying around. "select *" is the default, eager loading of relations is often a necessity, and the object/relational impedance problem makes it attractive to drag data to the webserver.

    If you want to speed up request times in PHP frameworks, all that matters is queries.
  • 0
    @Bitwise Magento 🤢
Add Comment