为什么访问我的数据库很慢?

Fab*_*ien 6 mysql startup

我有一个 mysql 数据库,它曾经工作得很好,但现在启动时速度很慢。当我输入

$> mysql -u foo bar
Run Code Online (Sandbox Code Playgroud)

在收到提示之前,我收到以下通常的消息大约 30 秒:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Run Code Online (Sandbox Code Playgroud)

当然,我试过了,速度快了很多:

$> mysql -u foo bar -A
Run Code Online (Sandbox Code Playgroud)

但是为什么我要在常规启动中等待这么长时间?这不是一个很大的数据库(编辑:<10 MB),并且数据似乎没有损坏(启动后一切正常)。我没有其他客户端同时连接到 mysql 服务器(命令只显示一个进程show full processlist)并且我已经重新启动了该mysqld服务。

这是怎么回事 ?

Rol*_*DBA 3

我认为问题源于自动重新哈希功能

我今天尝试了这个

在 mysql 提示符下,我输入

mysql> desc outbound_
Run Code Online (Sandbox Code Playgroud)

我点击标签两次并得到以下信息

mysql> desc outbound_
outbound_call_id                      outbound_log.ext                      outbound_log.template_id
outbound_log                          outbound_log.failed                   outbound_log.transfer_connected
outbound_log.DealerVoiceProviderType  outbound_log.icallclick_alert         outbound_log.transfer_duration
outbound_log.VoipCallStatusType       outbound_log.isService                outbound_log.transfer_ended
outbound_log.VoipTransferStatusType   outbound_log.lead_id                  outbound_log.transfer_ext
outbound_log.call_duration            outbound_log.outbound_log_id          outbound_log.transfer_phone
outbound_log.call_ended               outbound_log.phone                    outbound_log.transfer_started
outbound_log.call_started             outbound_log.postback                 outbound_log.transfer_status
outbound_log.call_type                outbound_log.recording_url            outbound_log.vehicle_id
outbound_log.called                   outbound_log.remote_call_id           outbound_log_id
outbound_log.callnote_synced          outbound_log.sales_id
outbound_log.dealer_id                outbound_log.scheduled
mysql> desc outbound_
Run Code Online (Sandbox Code Playgroud)

每个数据库和表都出来供我选择

显然,mysql客户端要读取information_schema数据库。如果您的 mysql 实例包含大量 InnoDB 表,我可以看到auto-rehashmysql 客户端停止运行,直到它可以读取information_schema数据库。