Doctrine 1
  1. Doctrine 1
  2. DC-403

Eliminate queries produced by Doctrine_Node_NestedSet::getDescendants() when possible

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.0
    • Component/s: Nested Set
    • Labels:
      None

      Description

      How to reproduce

      1. fetch a tree with nested set
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId()); 
        
      2. issue
        $root->getNode()->getChildren();
        
        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...
        
        

      Problem is described more verbosely here – http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

      What behavior is expected

      An already fetched record instance is returned, without calling database and without causing query flooding.

      Like in propel.

      In propel if you are calling ....::retrieveTree($id) it returns the root
      with completed, pooled (cached) and linked tree.

      What happens

      An additional query is issued

      This is a big slip in architecture of Doctrine`s nested set implementation.

        Activity

        alex created issue -
        Andrei Dziahel made changes -
        Field Original Value New Value
        Summary Normal nested set pooling implementation Eliminate queries produced by Doctrine_Node_NestedSet::getDescendants() when possible
        Description There is no normal nested set pooling in Doctrine.

        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        $root=$tree[0];

        After every $root->getNode()->getChildren() there is a unnecessary queue to DB.
        Please, we need to implement normal nested set without flooding queues.
        h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();
        {code}

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database

        h3. What happens
        An additional query is issued
        Priority Critical [ 2 ] Major [ 3 ]
        alex made changes -
        Description h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();
        {code}

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database

        h3. What happens
        An additional query is issued
        h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
          <?php foreach($child->getChildren() as $childChild): ?>

          <?php endforeach; ?>
        <?php endforeach; ?>
        ...

        {code}
        h1. Problem well described here:
        http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        alex made changes -
        Description h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
          <?php foreach($child->getChildren() as $childChild): ?>

          <?php endforeach; ?>
        <?php endforeach; ?>
        ...

        {code}
        h1. Problem well described here:
        http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...

        {code}
        h5. Problem well described here:
        http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database and without causing query flooding.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        Andrei Dziahel made changes -
        Comment [ Rewrote ticket description ]
        Andrei Dziahel made changes -
        Description h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...

        {code}
        h5. Problem well described here:
        http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database and without causing query flooding.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...

        {code}

        Problem is described more verbosely here -- http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database and without causing query flooding.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        alex made changes -
        Description h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...

        {code}

        Problem is described more verbosely here -- http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database and without causing query flooding.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation. Thank you.
        h3. How to reproduce

        # fetch a tree with nested set
        {code}
        $root = Doctrine::getTable($model)->getTree()->findRoot($rootId);
        $treeObject= Doctrine::getTable($model)->getTree()->fetchTree($root->getId());
        {code}
        # issue
        {code}
        $root->getNode()->getChildren();

        or there will be a total query mess in a lambda function with a loop getChildren().
        ...
        <?php foreach($root->getChildren() as $child): ?>
           ....
        <?php endforeach; ?>
        ...

        {code}

        Problem is described more verbosely here -- http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/

        h3. What behavior is expected
        An already fetched record instance is returned, without calling database and without causing query flooding.

        h3. Like in propel.
        In propel if you are calling ....::retrieveTree($id) it returns the root
        with completed, pooled (cached) and linked tree.

        h3. What happens
        An additional query is issued

        This is a big slip in architecture of Doctrine`s nested set implementation.
        Roman S. Borschel made changes -
        Assignee Roman S. Borschel [ romanb ] Jonathan H. Wage [ jwage ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-403, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            alex
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: