in reply to RE: (Package Data) RE: (3) You can't get there from here....
in thread References of Eternal Peril

In all probability, you're right. I'm trying to design a hack for a hack for a hack (or something along those lines) and I'm being stubborn and insolent by proceeding along this thought line. :-)

However, I should point out that the DBI author describes a 1:4 decrease in performance when switching from fetch (binded columns) to fetchrow_array. I'm not sure where fetchrow_hashref sits in relation to fetchrow_array, but I don't doubt it's as-bad or worse.

On the other hand, he also says that this is due to the limitations of Perl and how it handles memory, and not because of DBI or the database engine. So it's doubtful that this method will gain anything over fetchrow_hashref, as you said. But maybe it's work checking out.

I have no qualms about writing $a::name instead of $a->{name} if it's four (or even two) times faster. This also deserves to be compared to a standard bind_columns routine, and the fetchrow_arrayref ($a->[0]) method. There's very little doubt in my mind that bind_columns is fastest, followed by arrayref, hashref, then array. I'm just curious to see where this technique fits in, and if it can be adapted to increase A) readability in situations where fetchrow_arrayref is being used, and B) speed in situations where fethrow_hashref is being used.

<goes to dust of the ol' test tubes>

Alakaboo

Replies are listed 'Best First'.
RE: RE: (2) (Package Data) RE: (3) You can't get there from here....
by chromatic (Archbishop) on Aug 12, 2000 at 00:41 UTC
    The only other idea I have uses a list reference and a hash slice with bind_columns. I haven't tested this with DBI, but I did test it standalone.
    #!/usr/bin/perl -w use strict; my %h; my @cols = qw( one two three four ); @h{@cols} = ( 1 .. 4 ); assign( \( @h{ @cols } ) ); print "$_ => $h{$_}\n" foreach @cols; sub assign { my $val = 0; foreach (@_) { $$_ = $val++; } }
    There. You name your variables only once (outside of the template section), bind them to columns for speed, and are able to access them via a hash lookup. No symbolic references, and the only ugly construct is making a list of references from a hash slice. That beats the map stuff in my book, and it looks like a spaceship. You can't go wrong there.