[Rt-devel] [PATCH] Quote identifiers.

Ruslan U. Zakirov Ruslan.Zakirov at acronis.com
Sat Jan 22 14:26:47 EST 2005


Jesse Vincent wrote:
>>>Any reason you're assigning $self->dbi to $dbi and using that?
>>
>>you mean dbh? yes, it's required, because quote_identifier like quote is 
>>method of the database handle not statement.
>>
> 
> 
> 
> Er. Sorry. There's code of the form:
> 
> 
> my $dbh = $self->dbh;
> 
> $dbh->quote_identifier();
> 
> 
> Since it's just a reference, I don't quite understand the point.

Speed. See next benchmark
#!/usr/bin/perl -w
 
 

use strict;
use Benchmark qw(cmpthese);
my $obj = new Dummy;
 
 

cmpthese (-6, {
         'with $dbh' => sub { $obj->w_cache(); },
         'without $dbh' => sub { $obj->wo_cache() },
         });
 
 

package Dummy;
 
 

sub new { return bless { dbh => { foo => 'bar' } }, 'Dummy' }
sub dbh { my $self = shift; return $self->{'dbh'} }
 
 

sub w_cache {
	my $self = shift;
	my $dbh = $self->dbh;
	for(1..5) { my $x = $dbh->{foo} }
}
sub wo_cache {
	my $self = shift;
	for(1..5) {my $x = $self->dbh->{foo} }
}
Results:
                 Rate without $dbh    with $dbh
without $dbh 43465/s           --         -40%
with $dbh    72127/s          66%           --

Something similar happens in sub Insert I call quote_identifier in map 
context for each column, also dbh sub in SB::Handle more complex then in 
benchmark.

Similar situation in UpdateRecordValue.


More information about the Rt-devel mailing list