List:General Discussion« Previous MessageNext Message »
From:Benjamin Pflugmann Date:May 31 2002 6:42pm
Subject:Re: I need 50.000 inserts / second
View as plain text  
Hi.

On Fri, May 31, 2002 at 03:24:52PM +0200, admin@stripped wrote:
> Cesar, you really should consider using placeholders and bind_param (if
> available). Without using placeholders, the insert statement will contain
> the literal values to be inserted and has to be re-prepared and re-executed
> for each row. With placeholders, the insert statement only needs to be
> prepared once. The bind values for each row can be given to the execute
> method each time it's called. By avoiding the need to re-prepare the
> statement for each row, the application typically runs many times faster.

The general idea is correct, but note that MySQL does not support this
(yet) and therefore one should not notice any significant speed
difference.

(Of course, I do not mean to not use prepared statements, because
without, you won't get the performance boost once they are supported).

Bye,

	Benjamin.

> 
> BEFORE your loop, you prepare the query only once! Like this (in Perl),
> 
> $sth = $dbh->prepare ("INSERT into mynames (my_num, my_id) values (?, ?)");
> 
> Now, within your loop,
> 
> while (($name, $message_id) = each %posts) {
>     $sth->execute ($name, $message_id);
> }
[...]

-- 
benjamin-mysql@stripped
Thread
I need 50.000 inserts / secondCesar Mello - Axi31 May
  • Re: I need 50.000 inserts / secondJeremy Zawodny31 May
  • Re: I need 50.000 inserts / secondSteve Edberg31 May
  • Re: I need 50.000 inserts / secondHarald Fuchs31 May
  • Re: I need 50.000 inserts / secondMark31 May
    • Re: I need 50.000 inserts / secondBenjamin Pflugmann31 May
    • Re: I need 50.000 inserts / secondDan Nelson31 May
      • Re: I need 50.000 inserts / secondJeremy Zawodny1 Jun
  • Re: I need 50.000 inserts / secondMark31 May
  • Re: I need 50.000 inserts / secondCesar Mello - Axi31 May
    • Re: I need 50.000 inserts / secondmos2 Jun
  • Re: I need 50.000 inserts / secondRichard Clarke2 Jun
RE: I need 50.000 inserts / seconddomi31 May
  • Re: I need 50.000 inserts / secondCesar Mello - Axi31 May
    • Re: I need 50.000 inserts / secondT├Ánu Samuel31 May
    • Re: I need 50.000 inserts / secondBrent Baisley31 May