LoginSignup
3
5

More than 5 years have passed since last update.

【 Laravel 】LaravelのEloquentとPDOの実行時間を比較する

Posted at

結論

PDOの方がEloquentよりも5.7倍速い。

# 実行時間
Eloquent 0.01072883605957秒
PDO 0.0018770694732666秒
// Eloquent
$test = Test::whereBetween('id', [$start_id, $end_id])->get();

// PDO
$base = DB::connection()->getPdo()->prepare('SELECT * FROM test WHERE id BETWEEN :start_id AND :end_id');
$base->bindValue(':start_id', $start_id, PDO::PARAM_INT);
$base->bindValue(':end_id', $end_id, PDO::PARAM_INT);
$base->execute();
3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5