I have been running a benchmark on binding columns and working with the
results as opposed to directly dereferencing the returned reference. My
hypothesis was that the binding of columns must have some overhead
associated with it that could be avoided by directly dereferencing the
returned reference from $sth->fetch or $sth->fetchrow_arrayref. The results
are inconclusive at best. Sometimes one finishes faster, and sometimes the
other. That's fine, but can someone explain to me HOW bind_columns is able
to return the results as fast as directly dereferencing in the code (is
there no overhead to the binding of columns?).

Using two statement handles: source is $selecth and target is $inserth:

<direct deref snip>

while ($row = $selecth->fetch) {
$inserth->execute(@$row);
}

</direct deref snip>

<bind_columns snip>

$selecth->bind_columns(undef, \(@val[0..13]));
while ( $selecth->fetch) {
$inserth->execute(@val);
}

</bind_columns snip>

Only those two blocks are benchmarked, and the benchmark times average to
almost exactly the same.

Anyway, not earth shattering, but if someone can explain how bind_columns is
doing this as quickly as the direct dereference, (or maybe this is being
returned because my sample size is too small) I'd appreciate it.

Thanks,

Steve H.

Reply via email to