結論
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();