Bug #47061 Queries are executed too slow on Windows 7
Submitted: 2 Sep 2009 12:36 Modified: 2 Sep 2009 15:55
Reporter: Pavel Bazanov Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S5 (Performance)
Version:5.1.36, 5.1.37 OS:Windows
Assigned to: CPU Architecture:Any
Tags: slow queries, windows 7

[2 Sep 2009 12:36] Pavel Bazanov
Description:
MySql Server works very slowly on Windows 7 (version 6.1.7600). Simple queries take tens of milliseconds, while on Windows XP they take 0-1 ms. ALL queries are executed several times slower than on Windows XP. MySql server is on local computer (I mean queries are sent from the same PC).

All firewalls and antiviruses are turned off, UAC is turned off, logged in as administrator.

How to repeat:
Here is a couple of simple tests:

mysql> insert into customers set name = 'test';
Query OK, 1 row affected (0.02 sec)

//-----------------------------------------------------------------------------
private void BugWindows7()
{
	MySqlCommand command = OpenConnectionAndCreateCommand();
	Random r = new Random();
	command.CommandText = string.Format(
		"INSERT INTO customers SET Name = '{0}'",
		r.Next());
	Stopwatch sw = Stopwatch.StartNew();
	command.ExecuteNonQuery();
	sw.Stop();
	// The simplest query takes ~20 ms on Windows 7, while on Windows XP it takes 0-1ms
	MessageBox.Show(string.Format("The query execution took {0} ms", sw.ElapsedMilliseconds));
}

On Windows XP such queries take 0-1 ms:

mysql> insert into customers set name = 'test';
Query OK, 1 row affected (0.00 sec)
[2 Sep 2009 12:46] Pavel Bazanov
PS. Select queries are executed fast (0.00 sec), but insterts, updates and deletes are slow. Deletes are very slow:

mysql> DELETE FROM customers WHERE ID = 215;
Query OK, 1 row affected (0.40 sec)

mysql> DELETE FROM customers WHERE ID = 214;
Query OK, 1 row affected (0.71 sec)

mysql> DELETE FROM customers WHERE ID = 213;
Query OK, 1 row affected (0.02 sec)

mysql> DELETE FROM customers WHERE ID = 212;
Query OK, 1 row affected (0.02 sec)

mysql> DELETE FROM customers WHERE ID = 211;
Query OK, 1 row affected (0.04 sec)

mysql> DELETE FROM customers WHERE ID = 210;
Query OK, 1 row affected (0.34 sec)

On Windows XP:

mysql> DELETE FROM customers WHERE ID = 215;
Query OK, 1 row affected (0.00 sec)
[2 Sep 2009 14:04] Pavel Bazanov
I would not agree with changing severity to S5 (Performance). It's not a small problem. Our software can not work properly on Windows 7 at all, because it makes thousands of queries and now it takes very-very much time.

PS. If we run queries in transaction, they take 0-1 ms.
[2 Sep 2009 14:47] Valeriy Kravchuk
Thank you for the problem report. What storage engine do you use for these tables? MyISAM? Are you sure that disks and disk settings are the same as with XP then? I mean write cache is on etc...
[2 Sep 2009 15:49] Pavel Bazanov
I updated my RAID driver and the problem has gone. I have Intel ICH9R SATA RAID controller and Windows 7 installed April's 2009 version of the driver. I updated it a little bit to the june's version and now everything is ok. 
Thank you.
[2 Sep 2009 15:55] Valeriy Kravchuk
The problem was NOT related to any bug in MySQL server.