[CDBI] Re: extensive use of method Class::DBI::_fresh_init
"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
> 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 difference. 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: http://search.cpan.org/~tmtm/Class-DBI/lib/Class/DBI.pm#LAZY_POPULATION > my $species_id = $self->find_or_create(\%data); > $self->dbi_commit(); 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, Ed