Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing SQL statements from getting truncated by MySQL's Workbench in `Performance Reports` section

Recently I was introduced to the new feature of MySQL: performance_schema, and it's awesome. Specially when it's joined with MySQL Workbench's Performance Reports. I find the High Cost SQL Statements section pretty useful and practical. There's only one downside to it, the SQL column which holds the executed SQL statement is truncated in long cases.

I believe it's truncated by Workbench and not the performance_schema but I've got no solid evidence to prove it. Does anyone know how to have the complete version of SQL?

like image 498
Mehran Avatar asked Feb 28 '15 06:02

Mehran


People also ask

How do I limit a workbench in SQL?

You can easily change this limit by going to MySQL Workbench >> Edit >> Preferences >> SQL Queries tab. Over here you will option to Limit Rows. You can set this to very high value or uncheck the option. When you uncheck that option, it will retrieve all the rows from a query (equivalent to no limits).

How do I monitor MySQL database performance in workbench?

View server performance statistics in a graphical dashboard. To display the dashboard, open a query tab and then click Dashboard from the Performance area of the Navigator sidebar with the Management tab selected.

How do I enable performance schema in MySQL Workbench?

To enable all available Performance Schema instruments, pause your pointer device over Fully Enabled and click the circle on the slide bar. The SYS schema is bundled with MySQL Server 5.7 and above, and MySQL Workbench uses that version.


1 Answers

I managed to figure it out myself.

The information presented in MySQL Workbench's Dashboard are extracted using a series of views defined within sys database. The mentioned views are created based on the tables found in performance_schema database. The field responsible to hold SQL statements resides in sys.x$statement_analysis view which is taking it from performance_schema.events_statements_summary_by_digest table in turn. Even though this field is defined as LONGTEXT and can hold as many characters as 4G, but the SQL statements are truncated when they are inserted.

The maximum length of characters that will be inserted into DIGEST_TEXT is controlled by max_digest_length config. Its default value is set to 1024 and it can be increased as big as 1048576. But keep in mind that this config can be set on MySQL version greater than 5.6.24 only!!

like image 125
Mehran Avatar answered Sep 28 '22 02:09

Mehran