Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Performance #93

Open
busyapi opened this issue May 6, 2014 · 1 comment
Open

Performance #93

busyapi opened this issue May 6, 2014 · 1 comment

Comments

@busyapi
Copy link

busyapi commented May 6, 2014

First I'd like to emphasize I'm new to CouchDB/NoSQL and even if I've used Doctrine ORM for a few years now, I'm not an expert and I'm new to Doctrine ODM. So maybe the performance issues come from a misuse, misunderstanding, misconception or a bad configuration.

Let's say I have some kind of a tree structure with entities holding a relation to a parent entity (of the same type). Of course multiple entities of the same level may share the same parent entity.

Issue 1
Doctrine docs say the loading from the database is lazy and objects are really initialized whenever a method is called on the object. But when I fetch an entity with a find method or by querying a view with the include_doc parameter set to true, it turns out that not only Doctrine fully initialize the objects but it also fetch and initialize all related objects (and maybe all related objects of this related object and so on...) .

Issue 2
Doctrine fetch the same objet multiple times. Let's say I have 5 entities of the same level that share the same parent entity. Because of issue 1, Doctrine will need to access the parent entity 5 times. I thought Doctrine kept references to entities already fetched to avoid multiple fetches of the same entity but it turned out that Doctrine will fetch the parent entity 5 times...

Issue 3
From my understanding, an object will be fully initialized whenever a method is called. Given issues 1 and 2, this has major performance impact if you don't need other methods. I understand it avoids making multiple queries if multiple methods on the same object are called but maybe this behavior could be configurable so that a developer could choose the best strategy

To give you an exemple, for a tree containing 16 nodes on 2 levels, each low level node containing 2 documents for a total of 28 documents (2 nodes don't have any doc), Doctrine generates 51 requests to CouchDB ! On my development server it takes 4,1 seconds which is HUGE.

In my opinion, it should only generate 1 initial request + 16 other requests for the parent entities = 17 requests.

Needless to say I'm really scared about the performance I will get when I add more and more levels to the tree...

@beberlei
Copy link
Member

@johnatwassa could you post your entities here and their mappings?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants