<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft Internet Assistant for PowerPoint 97">
<TITLE>Hot handles</TITLE>
</HEAD>
<BODY >
<H1>Hot handles</H1>
<P><UL>
<LI><H2>Avoid using $dbh->do(
) in a speed-critical loop
</H2>
<UL>
<LI>Its usually creating and destroying a statement handle each time
</UL></UL><UL>
<LI><H2>Use $sth = $dbh->prepare(
)and $sth->execute() instead
</H2>
</UL><UL>
<LI><H2>Using prepare() gets a handle on the statement in the SQL cache
</H2>
<UL>
<LI>Avoids a round-trip to server for SQL cache check on each use
</UL></UL><UL>
<LI><H2>For example
convert looped
</H2>
<UL>
$dbh->do("insert
?", undef, $id)
<BR><BR> into $sth = $dbh->prepare("insert
?) before the loop
<BR> and $sth->execute($id) inside the loop
</UL></UL><UL>
<LI><H2>This often gives a significant performance boost
</H2>
<UL>
<LI>even where placeholders are emulated, such as the current DBD::mysql
<LI>because it avoids statement handle creation overhead
</UL></UL><UL>
<H2>.</H2>
</UL></P>
<P></P>
<P>
<TABLE>
<TD HEIGHT=100 WIDTH=100> <A HREF="tsld015.htm">Previous slide</A> </TD>
<TD HEIGHT=100 WIDTH=100> <A HREF="tsld017.htm">Next slide</A> </TD>
<TD HEIGHT=100 WIDTH=150> <A HREF="tsld001.htm">Back to first slide</A> </TD>
<TD HEIGHT=100 WIDTH=150> <A HREF="sld016.htm">View graphic version</A> </TD>
</TABLE>
<BR>
</P>
</Body>
</HTML>