foreach($files as $file) {
$justForTest = $file->type->id;
}
Doctrine profiler tells that there is one "execute" event, which DQL
seems like:
SELECT ...
FROM files f
INNER JOIN files_types f2 ON f.type_id = f2.id
WHERE f.type_id = ?
ORDER BY f.id DESC
LIMIT 2
And that is just what I expect.
If uncomment useResultCache(true) line and refresh page two times,
first query with INNER JOIN disappears, which also is expected because
of caching. But now profiler reports about two new additional queries
like:
SELECT ... FROM files_types f WHERE f.id = ?
Why does this happen, and is it correct behavior when using caching?
I don't think so. It sounds like the data from the FileType model is not being cached and re-constructed back from the cache properly. Can you create a ticket and test case?
> Doctrine profiler tells that there is one "execute" event, which DQL > seems like: > SELECT ... > FROM files f > INNER JOIN files_types f2 ON f.type_id = f2.id > WHERE f.type_id = ? > ORDER BY f.id DESC > LIMIT 2
> And that is just what I expect.
> If uncomment useResultCache(true) line and refresh page two times, > first query with INNER JOIN disappears, which also is expected because > of caching. But now profiler reports about two new additional queries > like: > SELECT ... FROM files_types f WHERE f.id = ?
> Why does this happen, and is it correct behavior when using caching?
So, since it isn't being reconstructed properly when you access the data it is issuing individual queries to lazy load the data when you access properties from the "type" join.
On Fri, Oct 31, 2008 at 8:06 AM, Jonathan Wage <jonw...@gmail.com> wrote: > I don't think so. It sounds like the data from the FileType model is not > being cached and re-constructed back from the cache properly. Can you create > a ticket and test case?
> - Jon
> On Fri, Oct 31, 2008 at 7:57 AM, Eugene Janusov <esy...@gmail.com> wrote:
>> Doctrine profiler tells that there is one "execute" event, which DQL >> seems like: >> SELECT ... >> FROM files f >> INNER JOIN files_types f2 ON f.type_id = f2.id >> WHERE f.type_id = ? >> ORDER BY f.id DESC >> LIMIT 2
>> And that is just what I expect.
>> If uncomment useResultCache(true) line and refresh page two times, >> first query with INNER JOIN disappears, which also is expected because >> of caching. But now profiler reports about two new additional queries >> like: >> SELECT ... FROM files_types f WHERE f.id = ?
>> Why does this happen, and is it correct behavior when using caching?
> I don't think so. It sounds like the data from the FileType model is not > being cached and re-constructed back from the cache properly. Can you create > a ticket and test case?
I've found what is the problem. Doctrine_Record::serialize() removes references before serialization, therefore data of joined models is not cached at all.
But then I've found that section "7.1.12 Serializing" of User Manual states: "Records can be serialized, but remember: Doctrine cleans all relations, before doing this." So, it looks like a "documented" behavior.
On Mon, Nov 3, 2008 at 11:04 PM, Eugene Janusov <esy...@gmail.com> wrote:
> Hmm. Can't understand…
> I've found what is the problem. Doctrine_Record::serialize() removes
> references before serialization, therefore data of joined models is not
> cached at all.
> But then I've found that section "7.1.12 Serializing" of User Manual
> states: "Records can be serialized, but remember: Doctrine cleans all
> relations, before doing this." So, it looks like a "documented" behavior.