[CDBI] Re: extensive use of method Class::DBI::_fresh_init
Edward J. Sabol
sabol at alderaan.gsfc.nasa.gov
Wed Jan 24 18:30:19 GMT 2007
> after finishing i recognized that performance is really slow and i
> started to use profilers in searching the bottleneck.
Class::DBI wasn't really designed for speed. If that's your main concern,
then you should probably be using a different module for database I/O. With
that said, there are some steps you can take to improve speed.
If you look at the code (CDBI v3.0.16), _fresh_init() really doesn't do all
that much. You might want to try turning off the live object index:
$Class::DBI::Weaken_Is_Available = 0;
That might speed it up some, but I'd be surprised if that made a huge
Also, you might try specifying more (all?) of your tables' columns as
"Essential". That can dramatically reduce the number of database queries,
depending on what you are doing. In some cases it could actually reduce
performance, so you need to tread carefully. More info:
> my $species_id = $self->find_or_create(\%data);
I'm not a big fan of the find_or_create() method. The result is that you're
calling dbi_commit() even when the species_id is found. That could be a
bottleneck, but maybe it isn't. Personally, I would retrieve() it first. If
not found, then insert() and dbi_commit() only if the retrieve() fails.
Hope this helps,
More information about the ClassDBI