EmergencyEMERGENCY? Get 24/7 Help Now!

Using per-query variable statements in Percona Server

Posted on:



Share Button

Percona Server has implemented per-query variable statement support in version 5.6.14-62.0. This feature provides the ability to set variable values only for a certain query, after execution of which the previous values will be restored. Per-query variable values can be set up with the following command:


If we want to increase the sort_buffer_size value just for one specific sort query we can do it like this:

Using the per-query variable statements with Statement Timeout feature

Percona Server has implemented a statement timeout feature (This feature with some changes was ported from Twitter MySQL patches). This feature can be used to limit the query execution time by specifying the timeout value in the max_statement_time variable. After the specified number of miliseconds is reached the server will attempt to abort the statement and return the following error to the client:

Following example shows how to limit the execution time for a specific query by using per-query variable statements with Statement Timeout feature:

This feature isn’t just limited to specifying one variable, we can provide more than one if we want to. Following example will both increase the sort_buffer_size value and limit the execution time:

Share Button



MySQL, Percona Server


Leave a Reply

Percona’s widely read Percona Data Performance blog highlights our expertise in enterprise-class software, support, consulting and managed services solutions for both MySQL® and MongoDB® across traditional and cloud-based platforms. The decades of experience represented by our consultants is found daily in numerous and relevant blog posts.

Besides specific database help, the blog also provides notices on upcoming events and webinars.
Want to get weekly updates listing the latest blog posts? Subscribe to our blog now! Submit your email address below and we’ll send you an update every Friday at 1pm ET.

No, thank you. Please do not ask me again.