Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Eloquent for performance design patterns

Using Eloquent for performance design patterns

Nemanja Maric

September 26, 2019
Tweet

More Decks by Nemanja Maric

Other Decks in Programming

Transcript

  1. About me • PHP Developer at Abstract • Member of

    PHP Serbia Community • Co-organizer Laravel Serbia Meetup’s • Working with PHP since 2014 • In Laravel world from 2016 • Open source contributor • Contributing to the Laravel Framework • And most !important: Husband and father of two little angels
  2. But why? Queries are super fast, but why is memory

    and execution time so big and what is this last 1012 models? Does someone know?
  3. Answer Because we do to much jobs in PHP and

    not in database. 1012 Models are custom metric in debugbar added by @reinink (Jonathan Reinink), is available from v3.2.6, it’s called “Hydrated Models” “It provides a quick count of how many Eloquent models were created during a request...which can have a huge impact on performance.“
  4. Requirement number 2 Order table data in two way: 1.

    Order by buddies first 2. Order by name
  5. This is heavy because we need to order by Pivot

    table. Everyone who sorted results like this knows that is this very heavy, unless? Order by buddies first, why is heavy?
  6. Questions? Leave review: https://joind.in/user/maki10 Slides: https://speakerdeck.com/maki10 Twitter: https://twitter.com/NemanjaMaki10 All credits

    go to @reinink and his Laracon 2019 talk. Watch him on Laracon2019 was very good choice, and it’s my advice for you to watch when he kicking a stage.