I am performing some MySQL queries that have very large result sets. I would like to see how long they take, but I don't want all the output to be printed on my terminal because it takes up a lot of space and time. I can do this by writing a script that performs and times the query, but I was wondering if there was a way to do this directly through MySQL on the terminal. Thanks.
3 Answers
Change the pager in mysql like indicated here: http://www.mysqlperformanceblog.com/2013/01/21/fun-with-the-mysql-pager-command/
mysql> pager cat > /dev/null will discard the output, and mysql> pager will put it back.
Comments
Wrap your query in set @foo = (select count(*) from ( ..... ) foo)
2 Comments
ejectamenta
this only seems to work for a single value which really limits the query
ysth
@ejectamenta: if you just have a single value, it can be shortened to
set @foo = (.....); with the select count...foo wrapper around it, you can put selects that return multiple values where I have .....Just run mysql console utility, then enter source file_name (where file_name contains sql commands)
1 Comment
abw333
I created a test.sql that has a simple command (select * from table limit 100) and ran "source test.sql". It runs the command, but still prints out the output.