api-platform / api-platform/core

[MongoDB] Use QueryBuilder when no lookup needed

未關閉
#7,995 6 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
doctrine MongoDB performance
主要語言
PHP
星號
2.6k
分支
980
平均合併
2 天 5 小時
30 天內合併 PR
48

描述

Hello, I'm testing mongodb odm support using **doctrine/mongodb-odm-bundle:4.0.0** and **api-platform/api-platform:2.5.0**

I'm experencing very poor performance with large datasets (2 million documents aprox.).
I suppose, it may be caused becase of use of Doctrine AggregationBuilder, for filtering and pagination.

I created a custom PaginationExtension using Doctrine Query/Builder instead with skip() and limit() methods and performance is 50x faster for the same dataset (partial pagination for now).

I tested command launched by Api Platform in mongo shell too::

`time mongo --eval 'db.users.aggregate([{"$sort":{"_id":1}},{"$facet":{"results":[{"$skip":0},{"$limit":30}],"count":[{"$count":"count"}]}}])' api-mongodb`
```
real 0m4.547s
user 0m0.061s
sys 0m0.026s
```
time mongo --eval 'db.users.find().skip(0).limit(30)' api-mongodb; mongo --eval 'db.users.count()';
```
eal 0m0.083s
user 0m0.057s
sys 0m0.007s
```
Is this something already detected? If the answer is yes...
Is there any plan at future releases to improve MongoDB integration performance avoiding use aggregates for Filters and Extensions?

Thanks in advance...

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。