Why is access to my database very slow? [closed]

I have a mysql database that used to work perfectly fine, but now it is dead slow on startup. When I type in

$> mysql -u foo bar

I get the following usual message for about 30 seconds before I get a prompt :

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Of course, I tried it and it goes a lot faster :

$> mysql -u foo bar -A

But why do I have to wait so long in regular startup ? This is not a very big database (edit : <10 MB), and data does not seem to be corrupted (everything looks fine after startup). I have no other client connecting to the mysql server at the same time (only one process is shown with the command show full processlist) and I have already restarted the mysqld service.

What's going on ?


Solution 1:

I think the problem stems from the auto-rehash feature

I tried this out today

At the mysql prompt, I typed

mysql> desc outbound_

I hit the tab twice and got the following

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_

Every database and table came up for me to choose

Evidently, mysql client has to read the information_schema database. If your mysql instance contains a lot of InnoDB tables, I can see auto-rehash stalling the mysql client until it can read information_schema database.

Solution 2:

Add the following to your [mysql] (notice it doesn't end with d) and it will greatly speed up your response time:

no-auto-rehash