[CDBI] Null Column Causing Repeated DB Calls

Aaron Dalton aaron at daltons.ca
Fri Feb 26 17:31:10 GMT 2010

On 26/02/2010 10:28 AM, Aaron Dalton wrote:
> On 26/02/2010 9:21 AM, eric.berg at barclayscapital.com wrote:
>> I'm optimizing one of my cdbi classes and found that one of my columns often contains a NULL value, and when I iterate through a set of results from a search_* query, when I attempt to do assignments of that attribute, cdbi is making another call to the db just to retrieve that value, when it's value is NULL slowing things down considerably.
>> I'm about to try to override the accessor for that column, but I'm wondering if there's a way to address this issue within cdbi in general.
>> Anybody have any advice on the matter?
> I'm a relative n00b, but can't you just declare that column as "Other"?
>  That should mean it won't every fetch the value unless explicitly
> requested.
> http://search.cpan.org/~tmtm/Class-DBI-v3.0.17/lib/Class/DBI.pm#LAZY_POPULATION

Oops!  Re-reading your message, what you would do is set the column as
"Essential" so it is immediately loaded at construction time, obviating
the need for separate DBI calls.


More information about the ClassDBI mailing list