A split query join optimization

Given the schema (relations and foreign keys omitted for brevity):

CREATE TABLE foo (id, name);
CREATE TABLE bar (id, name);
CREATE TABLE foo_bar_map (id, foo_id, bar_id);

INSERT INTO bar VALUES (1,"BAR");
INSERT INTO foo VALUES (1,"Foo 1"),...,(1000,"Foo 1000");
INSERT INTO foo_bar_map VALUES (1,1,1),...,(1,1000,1);

and the following query:

my $rs = dbr_connect('my_schema')->foo->all;
while (my $r = $rs->next) {
    print $r->name,"\t",$r->bar_maps->next->bar->name,"\n";
}

then the previous code would make a hair over 1000 queries, or 2000 on a cold
cache, because each bar_maps resultset is treated as independent and cannot
amortize the bar query with its siblings.  This has been changed to allow the
rowcache to cross query-splitting boundries, reducing the above to 3 selects (6
cold).