How to get full query text from performance_schema.threads?

All we need is an easy explanation of the problem, so here it is.

According to documentation:

Access to the threads table does not require a mutex 
and has minimal impact on server  performance. The other
sources have negative performance consequences because they require a mutex. 

So yes, I want to use threads table to examine running queries. The trouble is, the PROCESSLIST_INFO column does not contain the full query. It just contains a truncated version of the query. There is a flag viz performance_schema_max_sql_text_length which controls how many bytes are allocated for the SQL query. But it seems to affect the events_statements_history_long table. There is no change in the thread table output. There is also the events_statement_current table. But it is not clear if accessing that table affects performance or not.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Digging more into documentation:

The Performance Schema is intended to provide access to 
useful information about server execution while having minimal
impact on server performance

It looks safe to use performance_schema.events_statement_current for monitoring currently running queries and events_statement_current.SQL_TEXT gives full query text as long as it fits performance_schema_max_sql_text_length bytes.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply