Search code examples
query-buildereloquentrawsql

Speed comparison between Eloquent ORM, Query Builder, and Raw SQL Queries


Does anyone has the data of speed comparison between Eloquent ORM, Query Builder, and Raw SQL Queries? What is the better choose?


Solution

  • Raw SQL will always be the fastest because a human can always optimize the code and script to their liking. The query builder (aka Fluent) will be the next fastest, only slightly slower than Eloquent. That's because Eloquent uses Fluent within itself along with its own models and relationships.

    If you're looking for pure processing speed, use raw SQL.

    Otherwise use Eloquent for fastest development UNLESS you have no models and relationships, then use Fluent.