When using drush sql cli, table names do not autocomplete because mysql is invoked with "-A" (--no-auto-rehash). The mysql command line tool asserts you can "get a quicker startup with -A", however real-world testing shows the speed difference is insignificant.

Benchmark:

5000 invocations, MySQL query cache off, large-ish drupal site with 150 tables and about 130MB of disk space used.
Using expect to simulate interactive mode, the cost of --auto-rehash was 0.062 seconds.
When using STDIN (e.g.

drush sql cli < data.sql</code) the cost was 0.000007 seconds.  (i.e. unmeasurable).

So it would seem that not only is the startup time small, <code>mysql

seems smart enough to detect when STDIN is present, and suppress the rehash so there is no startup cost at all in that case.

Comments

moshe weitzman’s picture

Status: Needs review » Postponed (maintainer needs more info)

Perhaps startup time only matters for servers with many tables. Please benchmark this case.

moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Needs review

Oh, I missed your statement about 150 tables. I'm OK with this change. Anyone else care to comment?

grendzy’s picture

Heh, I was about to ask how many tables would be enough? Certainly someone doing table prefixing with a multi-site install could see far more.... but that would be doing it wrong.

Should we consider making it configurable via drushrc, similar to #518184: Allow Users To Set myqldump Arguments In drushrc.php (for drush sql dump) ? FWIW, I would also like to add default-character-set=utf8.

rsvelko’s picture

to sum up:
1. we want to be able to add some defaul sql options in the drushrc

2. this issue here suggests that we add 2 more default options for "sql cli" :
--default-character-set=utf8.
--auto-rehash

please follow the progress of #518184: Allow Users To Set myqldump Arguments In drushrc.php (for drush sql dump) form now on - this thread's patch will be there too

rsvelko’s picture

moshe weitzman’s picture

Status: Needs review » Fixed

I removed the -A. Committed.

Status: Fixed » Closed (fixed)
Issue tags: -sql additional arguments patch

Automatically closed -- issue fixed for 2 weeks with no activity.