Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Intentionally Create a Long-Running MySQL Query

Tags:

mysql

testing

I know this is an odd question to ask, but I'd like to find out if there is a MySQL query I can create without already having millions of rows in my database that will consume resources and run for a long time. My ultimate goal is to test my application in cases of resource contention and make sure that my methods for handling failure (specifically server timeout) are correct.

If there another way I can test this without creating and executing a high-resource query, I'd appreciate hearing that as well.

like image 720
justkt Avatar asked Oct 08 '10 16:10

justkt


People also ask

What is the maximum length of MySQL query?

The MySQL maximum row size limit of 65,535 bytes is demonstrated in the following InnoDB and MyISAM examples. The limit is enforced regardless of storage engine, even though the storage engine may be capable of supporting larger rows.

How long should a MySQL query take?

There's no worry as long as there's no problem. A query can take up to one hour if it crunches extremely large amount of data once every 6 months in a system where only it is running. It won't be a problem. Another query can take 100ms only but it's on a web server and 1000 persons are connecting simultaneously!

How do I set query timeout in MySQL?

Log in to your server by using Secure Shell® (SSH). Use the sudo command to edit my. cnf , the MySQL® configuration file. Locate the timeout configuration and make the adjustments that fit your server.


1 Answers

I assume you could use benchmark() for this, although that isn't the scope of it.

select benchmark(9999999999, md5('when will it end?'));
like image 162
mhitza Avatar answered Oct 07 '22 19:10

mhitza