View Single Post

   
  #5 (permalink)  
Old 02-28-2008, 07:10 AM
Dikkie Dik
 
Posts: n/a
Default Re: Why is my MySQL database so slow

Speaking about test: are you running the database, the webserver and the
client on the same machine? In that case, you machine may be busy
emulating network traffic AND performing the task.

Best regards

Stefan Mueller wrote:
> I've created my first MySQL table 'mytable' with two fields (key_mytable,
> code):
> CREATE TABLE `mytable` (
> `key_mytable` int(10) unsigned NOT NULL default '0',
> `code` varchar(12) collate latin1_german1_ci default NULL,
> PRIMARY KEY (`key_mytable`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci
> COMMENT='mytable';
>
> With the following PHP script I'd like to add 2000 entries.
> <?php
> ...
> \\ Delete all entries
> $table = "mytable";
> $query = "TRUNCATE " . $table;
> mysqli_query($link, $query);
>
> \\ Add entries
> for ($i = 1; $i <= 2000; $i++) {
> $table = "mytable";
> $query = "INSERT INTO " . $table . " (key_mytable, code) VALUES ('" .
> $i . "', 'test')";
> mysqli_query($link, $query);
> }
> ...
> ?>
>
> But this is very very slow.
> After 30 seconds (after around 600 entries) PHP stops and shows the
> following error message:
> [01-Dec-2005 01:33:41] PHP Fatal error: Maximum execution time of 30
> seconds exceeded in D:\PHP\MyScript.php on line 35
>
> What's wrong?
> Stefan
>
>

Reply With Quote