MySQL Forums
Forum List  »  Perl

Re: How to use Query Cache with Perl DBI
Posted by: David Shrewsbury
Date: September 03, 2006 07:07AM

Although prepare() may be called, I don't think the driver will necessarily prepare the statement unless there are parameter markers. For example, executing this basic script multiple times:

$dbh= DBI->connect("dbi:mysql:database=test;host=localhost", "", "");
$dbh->selectall_arrayref("select * from testaa");

I can see the Qcache_hits increase after the first call. Qcache_inserts also gets incremented. However, if you force server side prepares, like so:

$dbh= DBI->connect("dbi:mysql:database=test;host=localhost:mysql_server_prepare=1", "", "");
$dbh->selectall_arrayref("select * from testaa");

Then the query cache is not used at all.

If you turn on debugging when running the script, like:

DBI_TRACE=2 perl mytest.pl

you can see that in the first example, the prepare is actually skipped and the mysql_st_internal_execute() function is used. If you force server side prepares, as in the second example, you'll see that mysql_stmt_prepare() is now called. So although prepare() may be called, the statement is not necessary prepared on the server.

-Dave

Options: ReplyQuote


Subject
Written By
Posted
September 01, 2006 10:20AM
Re: How to use Query Cache with Perl DBI
September 03, 2006 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.