<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Fri May 24 10:55:10 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-217/DDC-217.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-217] Result cache should cache the SQL result and not the final objects</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-217</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;When fetching objects and using a result cache, it would probably be better to cache the SQL result array instead of the hydrated objects. That way, when grabbing from the cache managed entities can be returned. Also, caching is more efficient since an SQL result array does not need to be serialized/unserialized when storing in apc or memcached.&lt;/p&gt;</description>
                <environment></environment>
            <key id="10634">DDC-217</key>
            <summary>Result cache should cache the SQL result and not the final objects</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="romanb">Roman S. Borschel</reporter>
                        <labels>
                    </labels>
                <created>Sat, 19 Dec 2009 13:49:14 +0000</created>
                <updated>Mon, 19 Dec 2011 16:44:04 +0000</updated>
                    <resolved>Sun, 30 Oct 2011 13:21:18 +0000</resolved>
                            <version>2.0-ALPHA3</version>
                                <fixVersion>2.2</fixVersion>
                                <component>ORM</component>
                        <due></due>
                    <votes>5</votes>
                        <watches>6</watches>
                        <comments>
                    <comment id="11552" author="beberlei" created="Sun, 31 Jan 2010 11:58:48 +0000"  >&lt;p&gt;It also avoids unnecessary &quot;proxy not initialized, can&apos;t serialize&quot; exceptions.&lt;/p&gt;</comment>
                    <comment id="12342" author="jwage" created="Thu, 18 Mar 2010 17:43:21 +0000"  >&lt;p&gt;If we make this change, the caching won&apos;t be &quot;as&quot; affective right since it will still have to go through the hydration process?&lt;/p&gt;</comment>
                    <comment id="12343" author="beberlei" created="Thu, 18 Mar 2010 17:48:28 +0000"  >&lt;p&gt;Correct, but its almost impossible to result cache entities because they are not allowed to have a single proxy entity at any depth of the object graph.&lt;/p&gt;

&lt;p&gt;Maybe we should introduce another notion of SqlResultCache? The ResultCache is good and effective for all Array and Scalar hydration modes, however the SQL Result caching is more useful for Object Hydration.&lt;/p&gt;</comment>
                    <comment id="12347" author="romanb" created="Thu, 18 Mar 2010 17:58:34 +0000"  >&lt;p&gt;Exactly. Yes it means hydration is always run but you really cant speak of &quot;effective&quot; when caching large object result sets because serialization &amp;amp; especially unserialization which then happens on every request will be pretty slow.&lt;/p&gt;

&lt;p&gt;As Benjamin said, result caching is perfect for anything but objects so this ticket really only affects queries that use object hydration. Storing the raw sql result for these has the advantage that the objects retrieved from the cache are not detached and thus need not be merged and also you dont have issues with uninitialized proxies preventing serialization.&lt;/p&gt;</comment>
                    <comment id="12377" author="jwage" created="Sat, 20 Mar 2010 01:47:01 +0000"  >&lt;p&gt;Is this also the cause of this issue? &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-446&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DDC-446&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we&apos;re unserializing some objects, does Doctrine know about them?&lt;/p&gt;</comment>
                    <comment id="12383" author="romanb" created="Sat, 20 Mar 2010 05:25:41 +0000"  >&lt;p&gt;Yes, as already said, objects coming from the result cache are currently DETACHED. Thus the EM does not care about them. This is fine if you just want to display them but if you want to modify them and persist new changes, you need to merge() the ones you want to become MANAGED again into the EM.&lt;/p&gt;</comment>
                    <comment id="12384" author="romanb" created="Sat, 20 Mar 2010 05:27:09 +0000"  >&lt;p&gt;It should also be noticed that if we make this change and the cached objects are managed after grabbing from the cache this can have a negative effect on flushing performance, if you only want the cached objects for read-only/display purposes. Maybe we should still provide both options, like Benjamin said.&lt;/p&gt;</comment>
                    <comment id="13817" author="romanb" created="Sat, 7 Aug 2010 07:00:42 +0000"  >&lt;p&gt;Moved to 2.1 for now.&lt;/p&gt;</comment>
                    <comment id="14872" author="dcousineau" created="Tue, 30 Nov 2010 15:09:53 +0000"  >&lt;p&gt;I would like to see the ability to cache pre-hydration as I have already run into this issue.&lt;/p&gt;

&lt;p&gt;Maybe the interface could be along similar syntaxes as turning on result caches&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$query-&amp;gt;useResultCache(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
      -&amp;gt;setResultCacheLifetime(3600)
      -&amp;gt;setResultCachePreHydration(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;); &lt;span class=&quot;code-comment&quot;&gt;//Result cache should work pre-hydration, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; caches &lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However from my examinations the hydrators will have to be rewritten to accept an array instead of a pdo statement.&lt;/p&gt;

&lt;p&gt;That would be my vote. If you don&apos;t have the resources to work on the ticket I can tackle it.&lt;/p&gt;</comment>
                    <comment id="14873" author="beberlei" created="Wed, 1 Dec 2010 03:25:29 +0000"  >&lt;p&gt;rewriting to use an array is not an option. this would require to call -&amp;gt;fetchAll() which is not wanted for the Iterate Result feature.&lt;/p&gt;

&lt;p&gt;There has to be a better way to redefine the method signatures to allow both use-cases.&lt;/p&gt;</comment>
                    <comment id="14874" author="beberlei" created="Wed, 1 Dec 2010 03:26:17 +0000"  >&lt;p&gt;Ah btw, any help is appreciated. Just Fork doctrine2 over at Github and develop this feature in a new branch (git checkout -b &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-217&quot; title=&quot;Result cache should cache the SQL result and not the final objects&quot;&gt;&lt;del&gt;DDC-217&lt;/del&gt;&lt;/a&gt;) and link it here or issue a pull request on Github.&lt;/p&gt;</comment>
                    <comment id="14880" author="dcousineau" created="Wed, 1 Dec 2010 15:55:26 +0000"  >&lt;p&gt;Forked here: &lt;a href=&quot;https://github.com/dcousineau/doctrine2&quot; class=&quot;external-link&quot;&gt;https://github.com/dcousineau/doctrine2&lt;/a&gt; though probably should pull it out into a local branch.&lt;/p&gt;

&lt;p&gt;I went ahead and went down that route of altering hydrators to accept an array as well as a statement. This way uncached queries will work with the statement as it used to, but can also hydrate from an array.&lt;/p&gt;

&lt;p&gt;As for the iterable hydrator you have a point but in this case you really can&apos;t cache it period, be it pre or post hydration (since to cache we have to serialize ALL the information).&lt;/p&gt;

&lt;p&gt;What I have up is working(ish with the caveat that I backported the changes to an earlier tagged release for our application and tested using that), take a look and see if we like or don&apos;t like how I did it.&lt;/p&gt;

&lt;p&gt;You&apos;ll notice I did split up _doExecute() for the query objects, because the DQL query object does so much analysis in the _doExecute() method which produces and attaches information (namely the result set mapping) that is depended on by the hydration process, I split it up into a &quot;doPreExecute&quot; function so that it can be called separately without actually executing the query.&lt;/p&gt;</comment>
                    <comment id="14885" author="beberlei" created="Thu, 2 Dec 2010 03:53:55 +0000"  >&lt;p&gt;Yes i know that the serialize thing won&apos;t work with the Iterator. My point was that the Iterator USES the Hydrator code and it should still support that use-case.&lt;/p&gt;

&lt;p&gt;See the IterableResult class and make sure that its still working after your refactoring.&lt;/p&gt;

&lt;p&gt;I don&apos;t like the instanceof check then iterate vs the forach over the array. I would rather find a solutio nthat works for both, but i cant find one now that doesnt involve findAll() (which is bad).&lt;/p&gt;</comment>
                    <comment id="14889" author="dcousineau" created="Thu, 2 Dec 2010 16:20:54 +0000"  >&lt;p&gt;I&apos;ll double check against the IterableResult and make sure it&apos;s compatible.&lt;/p&gt;

&lt;p&gt;Beyond that, I don&apos;t know what I could other than the instance of check. I could extend the statement object and create a statement that takes a flat array so all the code remains the same (i&apos;m passing a statement).&lt;/p&gt;</comment>
                    <comment id="15007" author="beberlei" created="Fri, 24 Dec 2010 04:50:38 +0000"  >&lt;p&gt;Assigning Guilherme&lt;/p&gt;</comment>
                    <comment id="15819" author="sobstel" created="Tue, 10 May 2011 10:50:31 +0000"  >&lt;p&gt;I&apos;ve made my own implementation for this:&lt;br/&gt;
&lt;a href=&quot;https://github.com/sobstel/doctrine2/commit/f583625f791da22dec77dd7d6c83b813f0bcbdaa&quot; class=&quot;external-link&quot;&gt;https://github.com/sobstel/doctrine2/commit/f583625f791da22dec77dd7d6c83b813f0bcbdaa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are no changes in specific hydrators and there is no fetchAll(). I&apos;ve added 2 wrappers: one for cached result array, and one for uncached pdo statement. The former (CachedResultStatement) is actually ArrayIterator which just implements used methods (fetch &amp;amp; closeCursor =&amp;gt; also specified in ResultStatementInterface). The latter is decorator for stmt, which just collects results on each call of fetch() (results are later available by calling getResult), and apart from this all calls are delegated to actual stmt object.&lt;/p&gt;

&lt;p&gt;I&apos;ve used (copied) following changes from Daniel &lt;a href=&quot;https://github.com/dcousineau/doctrine2/commit/c23b5a902da79ffc472c0769b9258775baf3189e&quot; class=&quot;external-link&quot;&gt;https://github.com/dcousineau/doctrine2/commit/c23b5a902da79ffc472c0769b9258775baf3189e&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Btw, what is your reasoning for not using fetchAll() anywhere?&lt;/p&gt;</comment>
                    <comment id="16032" author="hypno" created="Sun, 19 Jun 2011 11:44:23 +0000"  >&lt;p&gt;maybe a dumb question but is it normal that result cache fetched entities associations are set to blank objects?&lt;/p&gt;</comment>
                    <comment id="16197" author="bogdan.albei" created="Fri, 22 Jul 2011 16:12:02 +0000"  >&lt;p&gt;I&apos;ve sent a pull request for the fix(&lt;a href=&quot;https://github.com/bogdanalbei/doctrine2/commit/00d1aa2192b86e51872fbc833b2436354f6fe162&quot; class=&quot;external-link&quot;&gt;https://github.com/bogdanalbei/doctrine2/commit/00d1aa2192b86e51872fbc833b2436354f6fe162&lt;/a&gt;) . The changes were tested under live conditions sice v2.0.&lt;/p&gt;</comment>
                    <comment id="16654" author="beberlei" created="Mon, 17 Oct 2011 23:00:24 +0000"  >&lt;p&gt;Workaround for this issue: &lt;a href=&quot;https://gist.github.com/57e6b4deea566baac053&quot; class=&quot;external-link&quot;&gt;https://gist.github.com/57e6b4deea566baac053&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also: This will be fixed in 2.2.&lt;/p&gt;</comment>
                    <comment id="16687" author="beberlei" created="Sat, 22 Oct 2011 16:59:54 +0000"  >&lt;p&gt;First step of this hit DBAL today &lt;a href=&quot;https://github.com/doctrine/dbal/pull/69&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/69&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="16691" author="beberlei" created="Sun, 23 Oct 2011 21:37:31 +0000"  >&lt;p&gt;DBAL code was heavily refactored and merged, the ORM PR is now open for discussion:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/172&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/172&lt;/a&gt;&lt;/p&gt;
</comment>
                    <comment id="16725" author="beberlei" created="Sun, 30 Oct 2011 13:21:18 +0000"  >&lt;p&gt;Merged into master&lt;/p&gt;</comment>
                    <comment id="17049" author="beberlei" created="Mon, 19 Dec 2011 16:44:04 +0000"  >&lt;p&gt;Related Pull Request was closed: &lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/87&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/87&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                <issuelinks>
                        <issuelinktype id="10000">
                <name>Duplicate</name>
                                                <inwardlinks description="is duplicated by">
                            <issuelink>
            <issuekey id="12832">DDC-1279</issuekey>
        </issuelink>
                    </inwardlinks>
                            </issuelinktype>
                        <issuelinktype id="10001">
                <name>Reference</name>
                                                <inwardlinks description="is referenced by">
                            <issuelink>
            <issuekey id="11096">DDC-446</issuekey>
        </issuelink>
                    </inwardlinks>
                            </issuelinktype>
                    </issuelinks>
                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>