教义2比Laravel的Eloquent慢得多

时间:2016-01-05 20:54:01

标签: doctrine-orm laravel-5 eloquent

我尝试使用 Doctrine 2 LaravelDoctrine)代替 Eloquent

执行获取分页数据的简单查询:

// Doctrine
$orders = $this->orderRepository->paginateAll(50);
// Eloquent
$orders = $this->orders->paginate(50);

我最终用 Doctrine查询花费了太多时间(来自Laravel Debugbar的信息):

  • 学说查询花了3.86s

1.79s

SELECT DISTINCT id_0 FROM (SELECT o0_.id AS id_0, o0_.customer_id AS customer_id_1, o0_.customer_ref AS customer_ref_2, ... FROM orders o0_) dctrn_result LIMIT 50 OFFSET 0

16.63ms

SELECT o0_.id AS id_0, o0_.customer_id AS customer_id_1, o0_.customer_ref AS customer_ref_2, ... FROM orders o0_ WHERE o0_.id IN (?)

2.05s

SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT o0_.id AS id_0, o0_.customer_id AS customer_id_1, o0_.customer_ref AS customer_ref_2, ... FROM orders o0_) dctrn_result) dctrn_table
  • 雄辩查询花了50.38ms

36.73ms

select count(*) as aggregate from `orders`

13.65ms

select * from `orders` limit 50 offset 0

我没有在这里粘贴整个学说查询,因为表格中有65列,但它们都与' AS'一起使用,与提到的列相同。

这是教条2的行为是如此之慢还是我错过了什么?

我使用注释作为元数据进行映射,并使用Doctrine\ORM\EntityRepository来访问数据。

提前谢谢。

最诚挚的问候。

0 个答案:

没有答案