Page 1 of 1

MySQL very slow under Windows 8

PostPosted: 28. June 2013 15:34
by amln
I've recently upgraded from a Levovo X200 (Vista Ultimate 64 bit) to a Sony VAIO S15 (Windows 8 64 bit). The new notebook uses a processor which on paper is five times faster than the one in the old one.

The problem however is that MySQL is dead slow on the VAIO notebook under Windows 8. I have a routine which generates 24000 entries in a database, using the mysql_query PHP function. This routine took less than 50 seconds on the X200 under Vista 64, but now takes 1000-1200 seconds on the VAIO.

Initially I installed version 1.8.1 on the VAIO, then went back to version 1.7.7, but it didn't help. I also tried replacing "localhost" in the URL with "127.0.0.1" and it also didn't help.

Essentially it's the function mysql_query which, when called, takes 30-70 milliseconds to complete it's activities.

Looking at the task manager it appears that the hard disk (a 1TB HDD) is loaded at 100% while the processor is loaded with a few %. The HDD seems to be the limiting factor, but I have no idea why MySQL needs to access the HDD so much, given that the VAIO S15 has 12GB of RAM (the entire database would probably fit into max. 10-20MB of RAM). The old notebook with its slow processor and 8GB of RAM was much faster.

I wonder what could be done. Is there perhaps a way to tell MySQL to keep everything in RAM until the routine finishes the creation of the database and only after that write to the HDD?

Re: MySQL very slow under Windows 8

PostPosted: 28. June 2013 21:48
by hackattack142
Hello,

I suggest you give this page a read: http://dev.mysql.com/doc/refman/5.5/en/commit.html

Re: MySQL very slow under Windows 8

PostPosted: 28. June 2013 22:59
by amln
Impressive - that was the solution:

// before the loop:
mysql_query("START TRANSACTION;", $db);

// then the database loop over the 24000 entries

mysql_query("COMMIT;", $db);
mysql_close($db);

Reduced the execution time from 1200 seconds to 15 seconds.

BTW, what is this set of mysqli_* functions? Are they better than mysql_* functions?

Re: MySQL very slow under Windows 8

PostPosted: 28. June 2013 23:29
by Altrea
The mysql_ functions are tagged as deprecated since PHP 5.5 and will be removed completely from PHP core with one of the next major releases (PHP 5.6 or PHP 6) so you should take some time to read something about the alternatives mysqli and pdo

I prefer PDO because it is full OOP and does have multiple database adapters.

Re: MySQL very slow under Windows 8

PostPosted: 14. July 2013 18:12
by ronnelson
I changed my reference to 127.0.0.1 from localhost in the $sqlhost variable for the mysql_connect command in the code opening my connection to MySQL database. DRAMATIC DIFFERENCE is the time my pages (which all use MySQL) load.

<?PHP
$sqlhost="127.0.0.1"; <----- This used to say "localhost"
$sqluser="xxxx";
$sqlpassword="ppppppp";
$sqldatabase="dbdbdbdb";
$sqlconnection=mysql_connect($sqlhost,$sqluser,$sqlpassword)
or die ("Couldn't connect to SqlServer");

Re: MySQL very slow under Windows 8

PostPosted: 08. November 2013 15:46
by irosas
I suspect strongly that changing the value of the $sqlhost variable is the answer I need to solve my problem which is that both localhost AND 127.0.0.1 are loading super slow (I mean like 10 seconds to load). However, I don't know where to find that $sqlhost variable... I have xampp 1.8.1 and Windows 7 and my websites are joomla 2.5 and joomla 3.1 websites. Can someone pinpoint the path/file that must be edited? Thanks!!

Re: MySQL very slow under Windows 8

PostPosted: 08. November 2013 17:28
by Nobbie
irosas wrote:Can someone pinpoint the path/file that must be edited? Thanks!!


This is a question for a Joomla forum as it is an issue from Joomla.