I have developed some mysql queries for my application, and created indexes and used EXPLAIN
statements as well.
What types of testing methods we can use to check queries (performance testing, load testing, concurrency testing and others)
How to use those testing methods in your system, anything related to query testing is helpful to me.
Thanks in advance.
The mysql-test and client directories are located in the root directory of the distribution. For a MySQL binary distribution, mysql-test-run.pl is located in the mysql-test directory, and mysqltest is located in the same directory where other client programs such as mysql or mysqladmin are installed.
There are actually quite a number of ways to measure and benchmark queries in MYSQL: The simplest way is to run the query in the command line, MYSQL is set to show the query execution time by default. Similarly, with tools like MYSQL Workbench and PHPMyAdmin, the execution time will be shown after running the query.
You can test your MySQL skills with W3Schools' Exercises.
Test with sysbench , it is a great tool for simulating database traffic. Furthermore I would suggest getting familiar with the MySQL EXPLAIN statement as it helps to dissect a query and improve on slow areas.
There are quite a few articles on the internet that explain how to properly benchmark, here is just one of them http://20bits.com/articles/10-tips-for-optimizing-mysql-queries-that-dont-suck/ .
Last but not least there is no substitute for testing with real data. Theoretically speaking certain queries should handle better than others, but the only sure way to know this is by testing your schema with actual data. There is a handly tool named generatedata that creates a lot of dummy data so that you can perform said tests.
In order to properly benchmark your queries you must ensure any cached queries and database information is wiped so that the result times are accurate and independent of one-another; you can do this by performing a RESET QUERY CACHE
and FLUSH TABLES
before running each query.
Additional information as requested: From experience the best way to handle concurrency is by using the MySQL SET TRANSACTION statement to properly isolate your queries. By using the InnoDB engine the database will perform row locking which is often sufficient for most applications. You can test this by performing equivalent tasks on the database but with separate transactions. Concurrency is a very broad topic in the database world and I would highly recommend further researching this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With