-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issue with getParent and maybe other things #628
Comments
well we can make it possible for the user to configure the class in the annotation optionally and then throw an exception on a mismatch. |
Oh indeed, why not. Though not suitable for all cases, often you want a
|
I ran into this today while exploring performance around changing the fetch depth in my particular use case. Since the depth is a session-based setting, and the additional query happens within the scope of the original operation, it inherits the same depth setting. This actually can lead to a potentially very costly re-fetch of the same data. (For example, query with a depth of 3 on a node, and a companion query is issued for the parent that also has a depth of 3, getting most of the same object graph). A workaround to that particular issue is to zero out and then restore the session fetch depth in The ORM actually suffers from a similar problem with one-to-one relations on the non-owning side. The mapping knows there may or may not be an entity on the other side, and has no way of knowing whether or not to create a proxy without actually executing a query, at which point it of course has the object (or a null value). It's generally a bad way to map anything anyway, but happens often with legacy schema. The ORM workaround is to force a partial load of the entity with a query hint, knowingly leaving that association as a null value rather than a proxy. Such a hint might be a less invasive solution here, though. |
good point about the prefetch helper. another thing could be when i ask
for /parent/child to actually fetch /parent so that we have parent right
away. this could get expensive however if there are many siblings to child.
a query hint would tell phpcr-odm : i don't want the parent document to
be populated, leave it at null?
another idea: if the document itself would be a kind of a proxy, we
could catch access to the parent field and initialize the parent proxy
only at that point. we do know the parent path and we do know it must
exist. the only thing we don't know is the class and hence we can't
create the proxy of the parent without fetching data.
|
I noticed that if you map the
@ParentDocument
it seems that the parent node is eagerly loaded:https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L550
This is, I suppose, so that we know which class to create a proxy for, but obviously it almost defeats the point of creating a Proxy in the first place.
Doctrine ORM doesn't have this issue I guess. Any thoughts?
The text was updated successfully, but these errors were encountered: