2

I am working on JMeter with JDBC samplers. I have created the sampler with query type as Prepared Select Statement. I am using MySQL 5.5.

I have written a Select statement in the Query section. The parameters are mentioned in the Parameter values section along with their respective types in the Parameter types section. The parameters are fetched from a CSV file.

I ran the query and verified the results from View Result Tree listener. I am getting expected result. When I run my tests in multi threaded/ multi iteration mode, the results are satisfactory from the data retrieval perspective, however, from the Mysql log files, I found that instead of just setting the binding variables and executing the query, entire query was executed again as if it was as simple select statement.

It gives me an impression that though I have selected Prepared Select Statement as query type, it was executing the query as simple select statement.

Has anybody encountered this issue? What are the areas where I can look to resolve this issue? Configuration for my DB samplers

DB Sampler Info

Abhiram
  • 75
  • 9

1 Answers1

0

From what you show, for me JMeter is using PreparedStatements so binding is occuring.

What log in MySQL makes you think that binding is not occuring ? Are you sure that only JMeter is hitting MySQL ?

Could you set in user.properties:

log_level.jmeter.protocol.jdbc=DEBUG

Restart and show jmeter.log

JMeter is working fine, read this:

So change in the JDBC Connection Configuration the property "Database URL" to include :

?useServerPrepStmts=true

Community
  • 1
  • 1
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • Here are some of my findings. 1) MySQL allows client side as well as Server side Prepared Statements. By default server side prepared statements are not enabled. In such case if we select Prepared Select Statement in JMeter query type, it will emulate Client side prepared statement. We will still get the expected result, however, at the Database side, the statement will be executed as simple SQL statement. Here are the logs. – Abhiram Jan 06 '16 at 20:01
  • 3 Query SET character_set_results = NULL 3 Query SET autocommit=1 3 Query SET sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES' 3 Query SET autocommit=1 3 Query select a,b,c FROM TableName WHERE this_.STATUS<>"ERROR" AND this_.ACCOUNTID=1 AND this_.TIME_BLOCK BETWEEN '2015-10-20 15:10:02' AND '2015-11-03 11:39:00' 3 Query SET autocommit=1 3 Query select a,b,c FROM TableName this_ WHERE this_.STATUS<>"ERROR" AND this_.ACCOUNTID=2 AND this_.TIME_BLOCK BETWEEN '2015-10-20 09:47:37' AND '2015-11-03 13:47:37' 3 Quit – Abhiram Jan 06 '16 at 20:02
  • Above logs, we do not see any prepare statement being logged in the mysql logs. In order to make Server side prepared statements we have to pass "useServerPrepStmts=true" along with connection string. Once we pass this, we will get below logs. 34 Prepare select a,b,c FROM TableName WHERE this_.STATUS<>? AND this_.ACCOUNTID=? AND this_.TIME_BLOCK BETWEEN ? AND ? 160104 12:51:16 34 Query SET autocommit=1 34 Query SET autocommit=1 34 Query SET autocommit=1 34 Query SET autocommit=1 34 Query SET autocommit=1 This shows server side prepared statements are working. – Abhiram Jan 06 '16 at 20:08
  • I updated my answer, if Ok you should accept my answer and upvote – UBIK LOAD PACK Jan 06 '16 at 20:24