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

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


On Tue, 21 Oct 2008, Jess Robinson wrote:

>
> 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.

Oops, appears I was slightly off. DBIC overrides _quote, however it's only 
using a regex if and only if you provide an array of quotes to quote_char, 
otherwise it falls back to straight string concatenation as above.

And DBIC skips that if there is no quote_char. Sorry my bad.

I still don't believe its a huge resource drain tho, pleae prove with 
benchmarking.

>> 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
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: 
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



More information about the DBIx-Class mailing list