Ovid escribió:

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.

As a performance hack, I'd like to experiment with something like this:

  sub _init_from_real_thing {
    my $self = shift;

    my @attributes = $self->attributes;
    @{$sel...@attributes} = @{$self->_dbic->{_column_data...@attributes};

    return $self;
  }

Using the slices is a horrible encapsulation violation. I can deal
with that on our side, but not on the dbic side.  Is there a clean way
of fetching all of that at once?


Maybe you're looking for:

http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Row.pm#get_columns
http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Row.pm#get_inflated_columns

They seem to basically return a copy $self->{_column_data} (managing
inflated columns)

Best Regards,

Jose Luis Martinez
[email protected]


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to