api-platform / api-platform/core

[MongoDB] Use QueryBuilder when no lookup needed

Aberta
#7,995 6 comentários 2 reações 0 responsáveis Ver no GitHub
doctrine MongoDB performance
Linguagem predominante
PHP
Estrelas
2.6k
Forks
980
Merge médio
2d 5h
PRs com merge (30d)
48

Descrição

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...

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.