[Dbix-class] Newbie: resultset->cache

Jacek Grzebyta jgrzebyta at gmail.com
Mon May 12 23:59:03 BST 2008


Hi guys,

I am a new in the DBIx subject so sorry for my query. It might be 'stupid'  
for someone.

I found in the documentaton about resultset->set_cache &get_cache but i can 
not find how to use it. There is no example? So far about my case:

I have a table which has many relationships with different tables: so the 
query object definition looks like:

$result = $schema->resultset('Genotypes')->search(
	{ marker_id.id => \@markers},
	{ join =>[qw/marker_id genotypes_id genotypesatus_id dataset_id/]}
);

Than i collect data such like:
while(my $line->next) {
	my $marker_name = $line->marker_id->marker_name;
	my $acc_number = $line->genotypes_id->number;
	my $comment = $line->genotypestatus_id->comment;
}

The point is that one loop makes 3 queries to MySQL. Number of records is +/- 
150000 so it gives at least 3*150000 queries to database. I found that a lot 
of queries are the same. 

1)Cos i don't trust mysql cache is set_cache and get_cache a solution for me?
2) How to use it? Do you have any source code for study?

Thanks very much for help,
Jacek



More information about the DBIx-Class mailing list