[CDBI] quantity of DB queries

Oliver Jeeves oj at defuturo.co.uk
Fri Jul 28 10:32:35 BST 2006

I'm concerned about the number of queries Class::DBI would need to make 
to a database. My understanding is that if I were to do something like this:

my $obj = My::DB::Thing->retrieve(1);
my $some_value = $obj->fk->value;

Then CDBI would be doing something like the following:

Look up primary key values for row in Thing table
Look up fk value in Thing table for previously fetched primary keys
Look up primary key values for row in whatever table fk represents
Look up value in the fk table

Is that correct?

The trouble is, for a web application, I generally want to get something 
from the database, and then just work with those values without having 
to go back to the DB unless I need to look up a foreign key in another 
table. Does CDBI allow me to do this?

To clarify, in the above example, I would expect the following DB queries:

Look up all values for row in thing table.
Look up all values for row in table referenced by fk.

More information about the ClassDBI mailing list