How to perform load testing on Postgresql Database using jmeter.

1. download the postgresql driver class for JMeter: Download postgresql driver. put it to folder lib of JMETER.

2. Open Jmeter from : apache-jmeter_home/bin/jmeter.bat or ApacheJMeter.jar

3. Add Users

Select the Test Plan, right click on Test Plan, select Add> Threads(Users)> Thread Group
Set up the following fields for Users:
a. Set value for Numbers of Threads(users): 5
b. Set value for Ram-up Periods : 2.
It means that 5 users connect to MYSQL server withine 2 seconds.


4.Add JDBC Connection Configuration

Right click on the 'Thread Group', select Add > Config Element > JDBC Connection Configuration.
Set up the following fields for MySQL database:
a. Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. We have named it as 'Postgresqlpool'.
b. Database URL: jdbc:postgresql://IPAddress:PortNo/DatabaseName?autoReconnect=true
c. JDBC Driver class: org.postgresql.Drive
d. Username: username of database
e. Password: password of database
f.The other fields can be left as the defaults


5. Add JDBC Requests

Right click on the 'Thread Group', select Add > Sampler > JDBC Request.
Then, select this new element to view its Control Panel. Edit the properties as below:
a. Enter the Pool Name: Postgresqlpool (same as in the configuration element)
b. Query Type: Select statement
c. Enter the SQL Query String field.


6. Adding a Listener to View/Store the Test Results

Right click on the 'Thread Group', select Add --> Listener --> View Results Tree and Summary Report
Save the test plan, and run the test with the menu Run --> Start or Ctrl+R

10 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Cannot load JDBC driver class 'org.postgresql.drive'
    I get this error when I tried everything. Am I missing anything?

    ReplyDelete
    Replies
    1. i am getting this error too...Help please

      Delete
    2. PUT JAR RELATED TO THAT IN APACHE FOLDER/LIB

      Delete
    3. that's a typo. you need to add "r" at the end. it is "org.postgresql.driver"

      Delete
  3. Did you copy the driver into the jmeter lib folder?
    https://jdbc.postgresql.org/download.html

    Note that class name should be org.postgresql.Driver

    ReplyDelete
    Replies
    1. Yes the class name should be org.postgresql.Driver

      Delete
  4. i have had that driver in lib but still got "Cannot create JDBC driver of class org.postgresql.Driver' for connect URL 'jdbc:postgresql.

    ReplyDelete
  5. Hi, I am seeing this error "Cannot create PoolableConnectionFactory (ERROR: relation "dual" does not exist
    Position: 15)" and the URL I used is jdbc:postgresql://HostName:5432/qa

    ReplyDelete