Eloquent: Two HUGE Performance Mistakes

  • Two major performance mistakes in Eloquent are: excessive database queries and unnecessary loading of model relationships.
  • The first mistake is using a function that returns all customers and then counts them, resulting in a large number of database queries.
  • The second mistake is using the 'with' property to automatically load the relationship of an organization whenever a customer model is loaded, even when it's not needed.
  • Another issue is the incorrect order of SQL query components and unnecessary table joins.

via Eloquent: Two HUGE Performance Mistakes