Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries? - jdbc

Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries?
I have added two queries:

JMeter can do whatever underlying JDBC driver can do, for example for MySQL you can specify allowMultiQueries JDBC URL parameter and you will be able to separate statements by semicolon.
Looking into oracle pool variable name my expectation is that you're trying to test an Oracle database and its JDBC driver doesn't support this feature.
The options are in:
Create a stored procedure which will delete multiple records
Parameterize existing JDBC PreProcessor using i.e. __StringFromFile() function, in this case you will not have to copy and paste the preprocessors
Use JSR223 PreProcessor instead of the JDBC PreProcessor and implement your records deletion logic there, take a look at Statement.addBatch() function, you can combine multiple queries into one statement with it. Check out Using Statement Objects for Batch Updates chapter of the Retrieving and Modifying Values from Result Sets article for more details.

You can submit multiple queries as is, because you can't use ; in JDBC request
But you can use other techniques to insert/delete multiple records, for example using IN
delete from CPAY where bnf_nic_name in ('BillerBBJ929' ,'BillerOFV864')

Related

Return from query that refers tables in two different db

I have a goal where I need to write a query in JDBC postprocessor of JMeter but the tables used in query are in different databases. Some tables are in Db2 and others are in PostgreSQL.
I can connect and get response from two databases i.e. Db2 and PostgreSQL separately. However when I write query, that refer to tables in different db, I see relationship doesn't exist error.
I understand, I can use bound pool variables in JMeter for different db connections.
My question:
How can I use these bound pool variables, which are referring to different db (Db2 and PostgreSQL) connection in JMeter, in a single query, if that is possible. Maybe an example will help here, please?
If what I mention in 1 is not possible in JMeter, then how can I achieve above mentioned overall goal through JMeter?
It is not possible either "through jmeter" or "through" any other database client.
If you need to execute 2 separate queries at the same time - you can add 2 JDBC Connection Configuration elements for 2 databases, 2 JDBC Request samplers and a Synchronizing Timer.

Jmeter test database read performance

I am going to test database read performance with Jmeter Java Sampler.
Basically, query database 10000 times with primary key as query condition like ID with Thread group and Java Sampler.
I need to load 10000 records into database before executing the Thread Group.
The 10000 records will be looped for the 10000 times database read.
I have looked into the preprocessor of Jmeter. I can insert 10000 records into database in preprocessor, but I do not know how to pass the 10000 IDs to Thread Group or Java Sampler. It is too long to contact IDs as a String parameter.
How I can archive the purpose? Any comment is welcome.
Instead of inserting the data using PreProcessor I would rather recommend preparing the test data in setUp Thread Group. You can write the generated IDs into a file using i.e. Flexible File Writer and then read them back with the CSV Data Set Config
If the database you're testing supports JDBC protocol it makes more sense to use JDBC Request sampler because JDBC Connection Configuration allows using connection pool pattern which most probably your application will be using when talking to the database, the main idea is to set up JMeter to produce the same footprint as the application which will be accessing the database.

BIRT Scripted Data Source using existing JDBC DataSource

I know that my overall problem is generally approached using two of the more common solutions such as a join data set or a sub-table, sub-report. I have looked at those and I am not sure this will work effectively.
Background:
JDBC data source has local data which includes a series of id's that reference a record in a master data repository interfaced via a web service. This is where the need for a scripted data source arises. The data can be filtered on either attributes within the local JDBC data and/or the extended data from the web service. The complication is that my only interface is the id argument to the webservice.
Ideal Solution:
Aside from creating a reporting table or other truly desirable scenarios I am looking to creating a unified data source through a single scripting data source that will handle all the complexities. This leaves the report generation and parameter creation a bit cleaner, hopefully. The idea is to leverage the JDBC query as well as the web service queries in the scripted data source do the filtering and joins and create that singular unified view.
I tried using the following code as a reference to use the existing JDBC connection in the BIRT report definition to execute the query. However if I think my breakdown on what should be in open vs fetch given this came from beforeFactory for a completely different purpose may be giving me errors...truth is I see no errors it just returns 0 records.
a link
I have also found a code snippet to dynamically load a JDBC connection but that seems a bit obtuse and a ton of overhead for what I am needing to do. a link
In short: How in all-that-is-holy do you simply run a query against a database within a scripted data source if you wanted to do. The merit of doing that is another issue, but technically how?
Thanks in Advance!

JDBC - Multiple queries in NamedParameterJdbcTemplate

Is there any way I can execute more than 1 query using a NamedParameterJdbcTemplate in one single call?
The simple answer: You can't. JDBC statements should execute only one query / statement at a time.
The longer answer: You usually can't, because either the driver or the database server doesn't support it, and formally the JDBC specification doesn't allow for it (if you read a bit between the lines in both the specification and the Javadoc). However, some driver (ie MySQL Connector/J) do allow you to execute multiple queries in one go (though you might need to specify a connection property to enable it, not sure).

CACHE of SQL in oracle

How oracle CACHE a Query (SQL), Query execution contains the following steps.
1. PARSE
2. Execute
3. Fetch
in First step oracle checks if query exists in CACHE (Shared Pool) or not (It will be exists if query is identical and based on LRU), if exists then PARSING will be skipped and execution will start.
So to make query performance intensive we must use bind variables and use the identical sql queries.
But in Parsing oracle verifies authentication also (User Access), if multiple users are using the same query, how oracle skip/use parsing?
The parsing of a query is not tied to a user, it is dependent on the query. Note that an exact character for character match is required. Blanks and comments in a query will cause it to miss the Shared Pool match.
The parse-tree is then used in the generation of an execution plan. If the same schema is used in the new query as the matched query then the existing execution plan is used.
You can test this by creating multiple schema, one with a small amount of data and one with a large
amount. Then analyze all the tables. Take a look at the execution plans for the same query with vastly different amounts of data. This will show the different execution plans for the same query.
Now run the query a large amount of times and check the amount of time that it takes for the first
and then subsequent executions. Use Oracle Trace and look in the left hand pain for the "Re-Parse"
frequency. This can also be gleaned from some of the dictionary tables.
Take a look at The Oracle documentation on using Oracle Trace
First step oracle checks if query exists in CACHE (Shared Pool) or not (It will be exists if query is identical and based on LRU), if exists then PARSING will be skipped and execution will start. So to make query performance intensive we must use bind variables and use the identical sql queries.
This is actual process when you execute a query on Oracle:
Parsing Steps
Syntax Check
Semantic Analysis
Has the query been executed in some other session?
Hard Parse
Parse
Optimize
Generate the plan for the query.
If the answer to #1.3 is yes - Oracle skips the hard parse portion, and uses the existing query plan.
For more info:
* AskTom: Difference between soft parse and hard parse
* Bind variables - The key to application performance
Usual practice in Oracle is to create stored procedures with definer rights which means that the queries are executed with privileges of their definer, despite of who calls them. That's why cache works well.
If you create a procedure or package with invoker rights (authid current_user), then the queries will be parsed for each invoker separately.
See Invoker Rights Versus Definer Rights for details.

Resources