How to Intentionally Create a Long-Running MySQL Query

爷,独闯天下 提交于 2020-02-27 04:37:55

问题


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.


回答1:


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

select benchmark(9999999999, md5('when will it end?'));



回答2:


For those wondering how to achieve a similar operation for MS SQL Server (not MySQL), use WAITFOR DELAY '02:00' if you want to test timeouts.



来源:https://stackoverflow.com/questions/3892374/how-to-intentionally-create-a-long-running-mysql-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!