[Dbix-class] Newbie: resultset->cache
Charles Alderman
charlie-lists at aldermania.com
Tue May 13 02:45:16 BST 2008
Jacek,
I'm new to DBIx::Class also, but I think your problem could be solved
by prefetching the data from the tables you joined. Implementation
would be easy -- just copy the join attribute and have join and
prefetch.
I'm not sure how get_cache is applicable to what you're working on b/c
I haven't really used it, but most RDBMS's are smart enough to apply
some sort of caching to frequently used queries (using placeholders as
DBIC does). If you end up prefetching, then you might be able to
eliminate a lot of the back and forth between your app and the db,
which could save you some network overhead.
Check out the examples here:
http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Cookbook.pod#JOINS_AND_PREFETCHING
Thanks,
Charles Alderman
----- Original Message -----
From: Jacek Grzebyta <jgrzebyta at gmail.com>
Sent: Mon, 12 May 2008 23:59:03 +0100
Re: [Dbix-class] Newbie: resultset->cache
> 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
>
> _______________________________________________
> 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/dbix-class@lists.rawmode.org
>
More information about the DBIx-Class
mailing list