<?xml version="1.0" encoding="windows-1252"?>
<node id="465041" title="Re: Speeding up the DBI" created="2005-06-09 06:06:29" updated="2005-08-11 18:10:38">
<type id="11">
note</type>
<author id="417993">
jbrugger</author>
<data>
<field name="doctext">
I found a nice article &lt;a href="http://gmax.oltrelinux.com/dbirecipes.html#fetching_a_hash_without_speed_penalty"&gt;here&lt;/a&gt;.&lt;br&gt;
Basically, you want large sets not in an arrayref, but as a hash, since it's more clear what column holds the data.&lt;br&gt;

e.g.
&lt;code&gt;
# tested this on live data, this is twice as fast as fetchrow_hashref, and has the same advantage..
# example taken from the link above.

my @fields = (qw(emp_id first_name monthly_payment)); 
$sth-&gt;execute;
my %rec =();

$sth-&gt;bind_columns(map {\$rec{$_}} @fields);

print "$rec{emp_id}\t",
      "$rec{first_name}\t",
      "$rec{monthly_payment}\n"
      while $sth-&gt;fetchrow_arrayref;
&lt;/code&gt;

*Update*&lt;br&gt;
Hmm, Funny indeed, anyway, i still consider this as a valuable way to speed up the DBI. :-)
&lt;br&gt;&lt;br&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-417993"&gt;
&lt;small&gt;"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
273952</field>
<field name="parent_node">
273952</field>
</data>
</node>
