Patrick Galbraith, Senior Systems Engineer, MySQL AB
Track: MySQL
Date: Wednesday, July 28
Time: 2:35pm - 3:20pm
Location: Salon D
TrackBack
MySQL, until version 4.1, didn't have server-side prepare statements in the C API (which DBD::mysql uses). With the current version of DBD::mysql, prepare statements with placeholders are emulated by simple string replacement, and results in having none of the benefits of using 'prepare' with placeholders, so many perl developers haven't really utilized the benefit of using placeholders in SQL such as with:
my $val1 = 1;
my $val2 = 'Test value';
my $sth = $dbh->prepare("INSERT INTO testtable VALUES (?, ?)");
$dbh->execute($val1, $val2);
Now that MySQL version 4.1 and later versions are available, it is possible to perform server side prepare statements in the C API, which results in much better performance. DBD::mysql will soon (well before the conference) have this functionality, which will give Perl developers the ability to use server side prepare statements, which in turn will give them better performance.
I intend to show the Perl developer briefly how this was accomplished in the driver code. Also, I will show them how to write applications that take advantage of this new functionality, such as how they can prepare a single SQL insert statement and simply pass the values they wish for their application to insert by simply calling 'execute' as in the previous example. I will detail how their application can benefit from this, and how it will result in fewer database calls, using a mod_perl database-driven web application as an example.
The other major functionality I will discuss is how the developer can utilize DBD::mysql with the MySQL embedded server. The MySQL embedded server gives the developer the ability to develop database driven applications without an external database, the database running inside the Perl application itself.
I will also discuss future ideas for DBD::mysql, such as named placeholders and cursors.