CloudSQL Query Insight - Query details truncated to 1024 characters
Query insights is a useful feature to help Cloud SQL users to detect, diagnose, and prevent query performance problems for Cloud SQL databases.
One client had an issue using it because their query was too long and it was truncated on Query details page. They asked if there is a config to show longer queries.
As always, I ran a lab to demonstrate how to fix this issue.
Firstly, I created a Cloud SQL MySQL instance and I ran a long query:
SELECT 1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`,
1 AS `blablahblahblablahblah`, 1 AS `blablahblahblablahblah`;
Below is what I saw in Query Insight:
I followed the help document to change to 4500 characters:
Customize query lengths
Default:
1024
Sets the query length limit to a specified value from 256 bytes to 4500 bytes. Higher query lengths are more useful for analytical queries, but they also require more memory. Changing the query length requires you to restart the instance. You can still add tags to queries that exceed the length limit.
But the issue is still there.
It turns out that MySQL has a default limit on the query size, there is a flag called max_digest_length
in MySQL. I will need to set it via Cloud SQL flag.
I set the flag to 4096 and I found the query not truncated in Query Insight.
Subscribe to my newsletter
Read articles from Derrick Qin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by