[Dbix-class] Q: Differing column names in DBIC and SQL

Jess Robinson castaway at desert-island.me.uk
Tue Oct 21 12:58:04 BST 2008


On Tue, 21 Oct 2008, Bernhard Graf wrote:

> Peter Rabbitson wrote:
>
>>> - AFAIR their usage slows down db access once more.
>>
>> Please bring some evidence for your last claim. If this turns out to
>> be true, someone will be happy to investigate this matter further.
>> However for now I and people whose opinion I value, consider this as
>> shameless FUD spread.
>
> AFAIR means that I don't have a source at hand, though it is quite
> obvious, that regex'ing each name in an SQL handle to insert
> quote_char-s and name_sep-s will slow down the process somehow.

Regex, what regex? Have you looked at the code that does this, or are you 
just guessing wildy? Cos it seems like the latter.

>From SQL/Abstract.pm:

$opt{quote_char} ||= '';
$self->{quote_char} . $label . $self->{quote_char}

So, it *always* runs that code, whether you set one or not!

Please check your accusations before spreading FUD.

> Or the other way round: Prefixing fields with underscore on deployment
> means faster queries than applying quote_char-s and name_sep-s in each
> query.


I haven't heard/seen this "common practice" anywhere.. But if you're 
determined, you want to define your columns as:

   _name => {
      accessor => 'name',
      data_type => 'varchar',
      ..
   }

To get the deploy system to create them with underscores in your database, 
while accessing them using the non-underscored versions in your code.

Jess




More information about the DBIx-Class mailing list