17 messages in com.mysql.lists.mysqlRe: DBI::quote problem
FromSent OnAttachments
d e l d h a n o a06 Sep 1999 21:15 
Eugene Miretskiy07 Sep 1999 13:29 
Joshua Chamas07 Sep 1999 13:42 
Eugene Miretskiy07 Sep 1999 14:00 
Joshua Chamas07 Sep 1999 14:12 
Eugene Miretskiy07 Sep 1999 14:24 
Joshua Chamas07 Sep 1999 14:29 
Jules Bean07 Sep 1999 16:20 
Joshua Chamas07 Sep 1999 16:34 
Joshua Chamas07 Sep 1999 16:43 
Paul DuBois07 Sep 1999 16:48 
Joshua Chamas07 Sep 1999 16:57 
Joshua Chamas07 Sep 1999 17:34 
Jules Bean08 Sep 1999 01:00 
Jules Bean08 Sep 1999 01:01 
Michael Widenius08 Sep 1999 05:42 
Joshua Chamas09 Sep 1999 04:20 
Subject:Re: DBI::quote problem
From:Paul DuBois (pa@snake.net)
Date:09/07/1999 04:48:24 PM
List:com.mysql.lists.mysql

At 6:35 PM -0500 9/7/99, Joshua Chamas wrote:

I didn't think you could prepare *any* queries with mysql. I thought that DBI::prepare was basically a no-op when using the Mysql driver (well, not quite - it stores the string locally, and does the ? substitution, but that's a local perl-side issue) - and I'd be surprised if it affected query speed much at all. (Unless, of course your overhead is perl, but that'd be surprising)

I don't know what's going on in the background, but between DBD::mysql & mysqld, there is a 35% speedup when preparing & caching cursors for simple insert statements. Supposedly there are no "server-side cursors" so I'm guessing its a client side thing.

What happens if you run your sets of statements in a different order? You may simply be seeing an effect of OS-level disk cacheing.

Here's a little benchmark that you can run:

use Benchmark;

# you supply the $dbi connection # create a database called spiders with a spider_id auto # incrementing column

timethis(2000, sub { my $isth = $dbi->prepare("insert into spiders (spider_id) values (NULL)"); my $nsth = $dbi->prepare("select last_insert_id()"); $isth->execute(); $nsth->execute(); $nsth->fetchrow_array; $nsth->finish; }); timethis(2000, sub { my $isth = $dbi->prepare_cached("insert into spiders (spider_id) values (NULL)"); my $nsth = $dbi->prepare_cached("select last_insert_id()"); $isth->execute(); $nsth->execute(); $nsth->fetchrow_array; $nsth->finish; });

prompt> bench_insert.pl timethis 2000: 10 secs (10.32 usr 0.00 sys = 10.32 cpu) timethis 2000: 7 secs ( 6.63 usr 0.00 sys = 6.63 cpu)

-- Joshua

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail mysq@lists.mysql.com instead.