1
1
I'm developing in PHP and MySQL locally using XAMPP on Windows. The web site is fairly fast when not connecting to any database. However, when I connect to the MySQL database, a simple request now takes approximentaly a second.
Note: This is not the case on my remote Debian vServer. My vServer handles requests fast, no matter if using a database or not.
I use Windows 8 x64 and the latest version of XAMPP and I did not commit any changed to the configuration files.
What could be the cause of this bad performance?^
Edit: This is the connection code I use:
$sql = new SqlConnection($cfgDbHost, $cfgDbUser, $cfgDbPassword);
$sql->setCurrentDatabase($cfgDbDatabase);
[...]
class SqlConnection
{
private $Link, $CurrentDatabase, $IsConnected;
function SqlConnection($host = 'localhost', $user = 'root', $pass = '')
{
$this->Link = @mysql_connect($host, $user, $pass);
$this->IsConnected = $this->Link != NULL;
}
function setCurrentDatabase($database)
{
if (@mysql_select_db($database, $this->Link))
{
$this->CurrentDatabase = $database;
return true;
}
else
{
return false;
}
}
[...]
1Use a SQL Browser (i.e.: HeidiSQL) and run some test queries directly against the database... do it on the server and from a remote computer and compare the times. It could be network, it could be memory, it could be MySQLs settings. – Wes – 2012-12-07T17:30:02.510
Using HeidiSQL, a query takes almost zero time. phpMyAdmin is also fast. I'll post the connection code. – bytecode77 – 2012-12-07T17:37:55.217
I uploaded the relevant code. Also I'd like to note, that the connection alone is the part that takes all the time. Even when no queries are fired, it takes like a second longer. – bytecode77 – 2012-12-07T17:42:10.730