日期:2014-05-16  浏览次数:20850 次

MYSQL 运行一小段时间后,速度变得奇慢。而CPU基本空闲状态!
【运行环境】:
WIN 2003 + APACHE2.2 + PHP5 + MYSQL 5.1.54

【服务器配置】:双核2.2G主频;1.5G内存;150G硬盘
【数据库情况】:
1. INNODB,ibdata 有30G
2. 有近2万张表,表的字段比较少(基本上10几个字段,最多有40个字段);
3. 大部分表的记录数,不超过3万条;只有个别表的记录有百万条的数量级。

【数据库使用情况】:
1. 连接只有几十个,其中,有几个连接是后台守护程序在用,查询和写入的频率很高(类似实时系统)。

【问题描述】:
1. 在MYSQL控制台下面,不管是什么操作(查询/更新),都非常慢(一张1万条记录的用户表,查记录数都要几秒~几十秒)。而此种情况下:mysqld占用约500M内存,CPU基本上都是2%(好像不工作)。重启MYSQL后,稍微好一点,但不一会,又开始很慢。
对比:最奇怪的是,之前的速度比较正常,mysqld 占用约500M内存,CPU占用50%,MYSQL查询速度比较OK(都是0.0X秒)。

我是MYSQL菜鸟,请大虾指教,是什么原因?


附:MYSQL配置:
# MySQL Server Instance Configuration File
# ----------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory 
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option 
# "--defaults-file". 
#
# To run run the server from the command line, execute this in a 
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a 
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
#
# CLIENT SECTION
# ----------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]

default-character-set=utf8


# SERVER SECTION
# ----------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
skip-name-resolve

# The TCP/IP Port the MySQL Server will listen on
port=3306


#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root
datadir="D:\Programs\MYSQL\data"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin