Hi Moritz,

Nope, you're misunderstanding how it works.

Search with prefetch fetches data and stores it in the resultset when next/all are called on the resultset.

However find() doesnt use prefetched data at all, there is no caching for find.

$rs->first, doesnt run any extra queries. Since that's now not part of the resultset any more, any rels called on the result of first() also produce more queries.

In short, it only works on chained resultset objects.

Jess


Thanks, that makes sense. But I recognized that the test case didn't exactly show
where my problem is. I edited the test:

my @rs =
  $schema->resultset("Complex")
  ->search( undef, { prefetch => { parents => "parent" } } );
for (@rs) {
        is( defined $_->parents->first->parent->id, 1 );
}

So now I'm not using find, but it still hits the database for every row.

New test is attached.

Attachment: test4list.tgz
Description: Binary data

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to