[CDBI] extensive use of method Class::DBI::_fresh_init
Stephan Steigele <steigele-PVbs4WEvWuCx/Y9o2RxMc8RkbBMU/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Organization | University of Leipzig - Computer Science Department - IZBI |
| Message-ID | <[email protected]> |
hi class:DBI list ..
hacking a tool for inter-connecting a postgresql db of mine
with a realy large genome-db, i used extensively class::DBI.
after finishing i recognized that performance is really slow
and i started to use profilers in searching the bottleneck.
using perl -d:DProf and dprofpp for profiling showed me
extensive calls of Class::DBI::_fresh_init.
----------
Total Elapsed Time = 2707.451 Seconds
User+System Time = 1558.051 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
45.3 705.8 717.09 144723 0.0049 0.0050 Class::DBI::_fresh_init
4.59 71.45 71.459 615286 0.0001 0.0001 DBI::st::execute
3.26 50.77 50.775 169356 0.0000 0.0000 Class::Accessor::Fast::__ANON__
2.83 44.10 89.181 155679 0.0000 0.0000 Class::DBI::Column::name_lc
2.06 32.14 121.31 155677 0.0000 0.0000 Class::DBI::Column::__ANON__
1.61 25.01 25.010 291473 0.0000 0.0000 DBI::common::FETCH
1.58 24.66 28.938 182872 0.0001 0.0002 Class::Std::new
1.17 18.17 20.970 558958 0.0000 0.0000 Class::DBI::_attribute_store
0.99 15.44 93.565 397898 0.0000 0.0002 Class::DBI::transform_sql
----------
what i MEAN to understand is, that calling Class::DBI::_fresh_init
always triggers a reconnection with db-server, is that right??
this would explain the large runtime ..
i think i am doing something completely wrong here. perhaps
someone could help me in finding a solution ..
what i am doing exactly is, that i have a 'database class', instantiating
Class::DBI, and for each db-table a separate class having the 'database class'
as base class. here are some snippets of both ..
my 'database class':
------
package Session::Database;
# File name: Database.pm.
use base 'Class::DBI';
use strict;
use warnings;
use Blasding::Session::Root;
use DBIx::Admin::TableInfo;
use Data::Dumper;
# encapsulate %config data
my %config = Session::Root->_read_config_file('~/.blasdingrc');
sub get_driver
{
my($self) = @_;
'Pg';
} # End of get_driver.
__PACKAGE__ -> set_db('Main', ('dbi:' . __PACKAGE__ ->
get_driver() . ':dbname='.$config{'DB'}{'Database'}), $config{'DB'}
{'User'}, '');
1;
-----
a class representing table ::
------
package Session::Database::Species;
use version; $VERSION = qv('0.0.1');
use Data::Dumper;
use warnings;
use strict;
use base qw( Session::Database);
use Session::Species;
sub set_species {
my ($self, $species ) = @_;
my %data;
$data{'taxon_id'} = $species->get_taxon_id;
$data{'species_name'} = $species->get_species_name;
$data{'trivial_name'} = $species->get_trivial_name;
my $species_id = $self->find_or_create(\%data);
$self->dbi_commit();
$species->set_species_id($species_id->species_id);
return $species;
}
----------
perhaps this examples help to clarify this (for me very annoying)
problem ..
thx in advance for any comment ..
stephan