[Dbix-class] Lazy loading of attributes?

Jesper Krogh jesper at krogh.cc
Fri Nov 11 00:25:19 CET 2005


Jules Bean wrote:
>> I have a table with some quite large attributes that only should be
>> fetched when they are accessed. In Class::DBI this was done by the
>> "columns(Other => qw(att1 att2)) but that seems to fail in DBIx::Class
>>
>> How is this typically done in DBIx::Class?
> 
> The defaulting to lazy attributes was responsible for a lot of poor 
> performance. I imagine that's why DBIC doesn't default the same way. 
> (It's far better to make one big query than 1000 small ones).

I can understand that...

> Unfortunately I don't believe there's a way of setting some attributes 
> to 'dont select by default', but what you can do is add the cols 
> attribute to your searches, as in 
> ->search({name=>"Jesper"},{cols=>qw/phone address email/}).

.. but I have a single attribute that contributes 230KB binary data, 
that I really would like to not load by default and only load when 
nessesary. This doesn't seem like an uncommon use-case to me.

So I really belive that the system should default to load all attributes 
(since the normal overhead is very low) and having an option to deselect 
automatically loading of specific attributes.

Jesper

-- 
Jesper Krogh



More information about the Dbix-class mailing list