[Dbix-class] Rapid Data Extraction

Ben Vinnerd ben-dbixclass at vinnerd.com
Tue Jan 12 10:42:04 GMT 2010


On Tue, 12 Jan 2010 02:26:41 -0800 (PST), Ovid
<publiustemp-dbic at yahoo.com>
wrote:
> Code in our Web templates is not allowed to touch the database.  Thus,
for
> each DBIx::Class result object, we extract the relevant data and put it
> into a simple object.  The relevant code looks like this:
> 
>   sub _init_from_real_thing {
>     my $self = shift;
> 
>     # from _real_thing
>     $self->$_( $self->_dbic->$_ ) for $self->attributes;
> 
>     return $self;
>   }
> 
> Creating one of these objects takes approximately 50 milliseconds. Each
of
> the individual channels or episodes you see on
> http://www.bbc.co.uk/iplayer/ represents one of these blocks.  If we
create
> 50 of these objects, that's 2.5 seconds -- way too long.

I'm curious as to why you're creating a simple object in the first
place. What is the reason for not allowing the web templates to not "touch
the database"? Is this any quicker, or is it for some security reason?

Ben



More information about the DBIx-Class mailing list