MySQL de-optimization

Is there a simple command that will allow me to configure an instance of MySQL DB to run slower than usual?

I am working on code that records and repeats interacting with databases. One of the things that it does is to keep track of how much time a given request / command needs to complete, and if it runs much slower during a replay, it will issue a warning. Of course, if you do not experience this, it does not work; I am trying to come up with an automated test for this feature. Is there something I can do with my test database that will ruin the performance? All I have to do is securely add 2+ milliseconds to any given request, and I am set up.

+7
source share
2 answers

If you just want to check long queries, do the following: SELECT SLEEP(1);

It doesn’t matter which request itself, if all you want to do is check if your duration detection works.

(I know this violates the true aspect of β€œreplay”, but it should be trivial to add SLEEP(1) during β€œreplay” to some select statements.)

EDIT:

A second idea that might seem better to you is to create a table lock from another connection. Run the script. Wait a bit. Remove this lock. It will not interfere with any of your playback requests.

+9
source

The basic procedure:

  • start a transaction

  • Make your sql stuff

  • 2 ms sleep in perl or sql

  • fixation

the key is part of begin / commit: it will store any locks you acquired, making things as slow as you want.

Other tests to consider:

  • start a transaction in two processes

  • Make your sql stuff in the first process

  • Make your sql stuff in the second process

  • make more sql files in each process

  • complete every process

+1
source

All Articles