Using JMeter to test JDBC databases
Despite JMeter is a well-known load testing tool when testing web projects, it seems to be unused when testing SQL performance. So I decided to share how to configure a fairly simple SQL test plan involving only one SQL statement.
Get a copy of the oracle driver (ojdbc14.jar) or a JDBC driver of your preferred DB, and throw it into the JMETER_HOME/lib directory
- Open JMeter and create a test plan as shown in fig1. Based on this plan you can complicate it as you want to load your DB and fit it to your needs. There are two JMeter Listeners (red) called “Aggregate Report” and “Summary Report” that will report us some statistical results like mean, median, throughput among others. I recommend you to use the Statistical Aggregate Report listener. Inside the thread group (blue) are two items of type “JDBC Connection Configuration” and “JDBC Request”. As we will see, is where we define the DB connection properties (user, password, driver, IP, SID), and the statement we want to test.
- We define in the thread group how many threads want to execute concurrently our statement (red) and how many times will be executed for each thread (blue).
- You must set a Variable Name (red) to reference this set of connection properties from other JMeter items.
Typical connection pool properties (blue and green), and connection configuration (pink). Note that the validation query may heavily impact in the tests.
- The “Variable Name” (red) must be the same you entered in previous step.
Now you’re about to choose the # of concurrent threads (users), pool size, testing time, and extract conclusions in your own environment!