[CDBI] Make name_lc go fast

Brad Bowman list at bereft.net
Tue Apr 3 02:23:25 BST 2007


After profiling a CDBI app I found that Class::DBI::Column::name_lc is
second on the list and in my case, actually does nothing, the names are
already in lower case:

# Original with name_lc
Total Elapsed Time = 40.13676 Seconds
   User+System Time = 39.33676 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
  11.9   4.685  4.685  16517   0.0003 0.0003  DBI::st::execute
  10.5   4.167  7.516 134747   0.0000 0.0000  Class::DBI::Column::name_lc
  9.67   3.804  3.804 146409   0.0000 0.0000  Class::Accessor::Fast::__ANON__

I removed the lc and used $_[0] and it made a slight difference to the

# No lc done
Total Elapsed Time = 34.38972 Seconds
   User+System Time = 33.78972 Seconds
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
  14.9   5.057  5.057  16517   0.0003 0.0003  DBI::st::execute
  10.1   3.431  3.431 146409   0.0000 0.0000  Class::Accessor::Fast::__ANON__
  9.72   3.283  6.499 134667   0.0000 0.0000  Class::DBI::Column::__ANON__

I've been trying to find a way to cleanly insert the lc-free code but
haven't yet succeeded.  I thought overriding _column_class would do it
but it just produced an error:

   Column line does not exist
   at /usr/share/perl5/Class/DBI/Relationship/HasA.pm line 11

Others at Perl Monks and in a journal had the same issue:


I hope to remove the name_lc overhead one way or another, does anyone
have any tips on how to do this nicely.  The only way I've found that
works is copying and editing Class::DBI::Column.  Is there another way?

Also, would it make more sense to avoid this in CDBI where possible?
Perhaps at column creation time, check that the lc is a noop and use
a alternative Column class?


     One should be careful with menials and the like.
     -- Hagakure http://bereft.net/hagakure/

More information about the ClassDBI mailing list