I recently transferred my site to another server, and when I ran a script that does a lot of statements UPDATE, I see it very slowly.
OLD_SERVER: Intel (R) Xeon (R) CPU E5-2650L 0 @ 1.80 GHz with 8 cores and 1,500 MB RAM
SERVER: Intel (R) Core (TM) i7-4770 CPU @ 3.40 GHz 8 cores and 32 GB of RAM + 2 ssd in RAID (10 times better than old)
** php script code **
$startTime = microtime(true);
$update_result = mysql_query("
UPDATE some_table
SET order_id = ".$random_order_id."
WHERE id = ".$row_get['id']."
");
$endTime = microtime(true);
$elapsed = $endTime - $startTime;
echo "Execution time : $elapsed seconds\n";
if(!$update_result)
{
return array(
"result" => false,
"code" => 502,
"reason" => "SQL Update error"
);
}
** OLD_SERVER script output (very fast): **
306497 will have order_id = 49438<br/>
Execution time : 0.00071907043457031 seconds
306505 will have order_id = 113556<br/>
Execution time : 0.00055885314941406 seconds
306508 will have order_id = 295573<br/>
Execution time : 0.00074100494384766 seconds
306511 will have order_id = 206028<br/>
Execution time : 0.00042295455932617 seconds
306518 will have order_id = 241993<br/>
Execution time : 0.00048589706420898 seconds
iotop renders 10MB/sec
** NEW_SERVER script output (very slow): **
10995 will have order_id = 94532<br/>
Execution time : 0.030339956283569 seconds
11021 will have order_id = 158848<br/>
Execution time : 0.060288906097412 seconds
11035 will have order_id = 288621<br/>
Execution time : 0.030526876449585 seconds
11059 will have order_id = 194945<br/>
Execution time : 0.031852960586548 seconds
11089 will have order_id = 176289<br/>
Execution time : 0.030807018280029 seconds
11102 will have order_id = 80207<br/>
Execution time : 0.059854984283447 seconds
11147 will have order_id = 33899<br/>
Execution time : 0.030609846115112 seconds
11392 will have order_id = 124314<br/>
Execution time : 0.031843900680542 seconds
11541 will have order_id = 249986<br/>
iotop renders 300KB/sec
** / etc / mysql / my.cnf **
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 256M
log_error = /var/log/mysql/error.log
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
!includedir /etc/mysql/conf.d/
innodb_log_file_size = 1G
innodb_io_capacity = 20000
innodb_read_io_threads = 5000
innodb_write_io_threads = 5000
Where is the problem? I do not understand.
Thank.
source
share