My database contains large no of tables (more than 300 tables ) . when I execute " use database name " command on mysql command line client , its taking very long time to execute. Is there any way we can make it execute faster. ?
You can pass the -A
argument to the mysql
command-line tool to make it not load database metadata when using a database.
That being said, what you're describing is usually a sign that either you have too many tables and/or columns, or your database server is overloaded. Often, it's both. Either one should be fixed.
I know its very old post but thought of writing about it as i also had the same problem in past and found this all
you would be having this problem when using cli while connecting mysql remotely this problem generally doesn't occur on localhost. As while using "use" command mysql check metadata of table and for loading it, it confirms host and credentials while connecting to mysql cli remotely and may be that slows down select DB, you could skip dns resolving but i don't think that will solve the problem completely
Hence "-A" tag/attribute have to pass with mysql command on connect remotely which will not load metadata while selecting DB using "USE" command.
for an example :-
mysql -A -h HOST -u USER -p