[Dbix-class] Question about lazy-loading of column data

Matt S Trout dbix-class at trout.me.uk
Tue Feb 7 16:06:01 CET 2006


On Tue, Feb 07, 2006 at 12:31:38PM +0100, Leandro Hermida wrote:
> 
> Hello,
> 
> I have tried to look at all of the DBIx::Class docs to find if it is
> possible to "lazy-load" or "load-on-demand" a certain column in a table
> using the DBIx::Class::Schema approach.  I have a DATA_FILE table with a
> very large BLOB/CLOB column holding the contents.  If I were to pull out a
> collection of DATA_FILE objects like:
> 
> my @data_files = $schema->resultset('DataFile')->all();
> 
> I wouldn't like the "contents" accessor for each object in the collection to
> be populated until I explcitly call $data_file->contents on a particular
> DATA_FILE object.  Is this possible with the DBIx::Class::Schema approach?

Currently there's no native lazy-loading code; a couple of people have
worked on patches but none of them have got to the point of submitting
them (if you did and I missed it, re-send it!).

You can, however, easily restrict the columns that get loaded by passing
the cols attribute to your search, and if you use $rs->next rather than
->all then the data will be fetched from the database one record at a
time so your memory usage shouldn't be too bad when you do fetch all
columns.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list