Bug #69486 mysql client waste time in sprintf making info messages that are not printed
Submitted: 16 Jun 2013 10:19 Modified: 1 Jul 2013 16:22
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S5 (Performance)
Version:5.6.12 OS:Any
Assigned to: CPU Architecture:Any

[16 Jun 2013 10:19] Shane Bester
Description:
Importing an sql file like this is typically done:

mysql test -uroot <file.sql

sets the client in batch mode.  That means by default the info messages:
"Query OK, 1 row affected"  are not shown.

It wastes some percentage cpu time to sprintf the message in com_go() but then discards it in put_info() because of batch mode and verbosity settings.

How to repeat:
Benchmark client that imports a large sql file containing many short lines.
See attached cpu profile..

Suggested fix:
Don't spend time generating messages that won't be output.
[16 Jun 2013 10:24] Shane Bester
cpu profile after excluding network read/write

Attachment: bug69486_cpu_profile_without_network_time.jpg (image/jpeg, text), 123.04 KiB.

[16 Jun 2013 10:32] Shane Bester
minor issue, really.  it may impact import time in the case a huge mysqldump created with --extended-insert=0 is imported against a very fast server running on localhost.

usually, combination of network vio and server processing will take long enough to mask this as an issue on the client.
[1 Jul 2013 16:22] Paul Dubois
Noted in 5.6.13, 5.7.2 changelogs.

In batch mode, mysql formatted result status messages such as ""Query
OK, 1 row affected"" but did not print them. Now these messages are
not formatted.