Reading table information for completion of table and column names

今天群里一同学问了一个问题,为什么在执行use db_name的时候会有如下提示:

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

我也很好奇,于是就google了一下,得到下面一段解释,老外的:

On the first "use" command after login, MySQL scans database, tables and columns name for auto completion. If you have many db, tables it could take a while.

To avoid that, launch your client with the -A option (or --no-auto-rehash)

mysql -uroot -p -A

You could also add the disable_auto_rehash variable in your my.cnf (in the [mysql] section) if you want to disable it completely. This change does not require a reboot (it is a client, not server, variable).

意思就是说,当你登录数据库第一次使用use命令的时候,mysql要去扫描相关的数据库、表、列名的信息,然后就会出现上面那段提示,如果不想显示,可以在登录的时候加上-A or --no-auto-rehash命令,另外一种是在my.cnf里的cliect里加上no-auto-rehash参数即可。

这个扫描动作也可以理解为收集统计信息,当数据库的数据量比较大的时候,你会发现执行use db_name时会卡住一段时间,不用紧张,转身去倒杯水,回来就好啦。

Vultr 新用户注册就送100$
shunzi
  • 本文由 发表于 2018-02-0812:41:38
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
在线音乐

在线音乐

Oracle Spool数据 BLOG

Oracle Spool数据

昨天有个需求,让我导出数据到txt文本,数据有150w 数据库是oracle,试了下spool方式导出非常快: Oracle Spool常用设置 命令 描述 set arraysize 1000; 此...
Mysqld_multi Stop Bug BLOG

Mysqld_multi Stop Bug

最近在做mysqld_multi管理多实例的时候,发现stop不了节点 这是什么原因呢? 多实例相关配置如下: mysqld = /usr/local/mysql/bin/mysqld_safe my...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: