Skip to main content
The QueryStressSettings class contains all configuration options for SQL Query Stress. These settings control test execution, connection behavior, statistics collection, and query parameterization.

Core Test Settings

NumThreads
int
default:"1"
Number of concurrent threads to use for the load test. Each thread will execute the query independently.The connection pool size is automatically set to NumThreads * 2 for optimal performance.
NumIterations
int
default:"1"
Number of iterations to run per thread. Each thread will execute the main query this many times.
DelayBetweenQueries
int
default:"0"
Delay in milliseconds between query executions within a thread. Set to 0 for no delay.

Query Configuration

MainQuery
string
default:""
The main SQL query to execute during the load test. This is the query that will be stress-tested.
"MainQuery": "SELECT * FROM Customers"
ParamQuery
string
default:""
Query to retrieve parameter values for parameterized queries. Results are used to populate parameters in the main query.See Query Parameters for detailed parameter configuration.
ParamMappings
Dictionary<string, string>
default:"{}"
Dictionary mapping parameter names to column names from the parameter query results.
"ParamMappings": {
  "@CustomerID": "CustomerID",
  "@OrderDate": "OrderDate"
}

Connection Settings

ConnectionTimeout
int
default:"15"
Connection timeout in seconds. Applied to both main and parameter database connections.Minimum value is 15 seconds (automatically adjusted if set to 0).
CommandTimeout
int
default:"0"
Command execution timeout in seconds. Set to 0 for unlimited timeout.
EnableConnectionPooling
bool
default:"true"
Enable or disable connection pooling. When enabled, connections are reused for better performance.
MainDbConnectionInfo
ConnectionInfo
Connection information for the database where the main query will be executed.See Connection Options for detailed connection configuration.
"MainDbConnectionInfo": {
  "Server": ".\\SQLEXPRESS",
  "Database": "Northwind",
  "IntegratedAuth": false,
  "Login": "dbUser",
  "Password": "!Se8ret"
}
ParamDbConnectionInfo
ConnectionInfo
Connection information for the database from which to retrieve parameter values.Only required if using parameterized queries with ParamQuery.
ShareDbSettings
bool
default:"true"
When true, the parameter database uses the same connection settings as the main database.Set to false if parameter values should be retrieved from a different database.

Statistics Collection

CollectIoStats
bool
default:"true"
Collect I/O statistics including logical reads during query execution.When enabled, sets SET STATISTICS IO ON before each query execution.
CollectTimeStats
bool
default:"true"
Collect timing statistics including CPU time and elapsed time during query execution.When enabled, sets SET STATISTICS TIME ON before each query execution.

Execution Behavior

ForceDataRetrieval
bool
default:"false"
Force the client to retrieve all data from the result set.When true, uses ExecuteReader() and iterates through all rows. When false, uses ExecuteNonQuery() for better performance.
KillQueriesOnCancel
bool
default:"true"
Cancel active SQL commands immediately when the test is cancelled.When true, does not wait for queries to complete naturally. A timer checks every 2 seconds and calls SqlCommand.Cancel() if cancellation is pending.

Complete Configuration Example

{
  "CollectIoStats": true,
  "CollectTimeStats": true,
  "CommandTimeout": 0,
  "ConnectionTimeout": 15,
  "DelayBetweenQueries": 0,
  "EnableConnectionPooling": true,
  "ForceDataRetrieval": false,
  "KillQueriesOnCancel": true,
  "NumThreads": 1,
  "NumIterations": 10,
  "MainQuery": "SELECT * FROM Customers",
  "ParamQuery": "",
  "ParamMappings": {},
  "ShareDbSettings": true,
  "MainDbConnectionInfo": {
    "Server": ".\\SQLEXPRESS",
    "Database": "Northwind",
    "IntegratedAuth": false,
    "Login": "dbUser",
    "Password": "!Se8ret",
    "ConnectTimeout": 15,
    "EnablePooling": true,
    "MaxPoolSize": 2,
    "ApplicationIntent": 0
  },
  "ParamDbConnectionInfo": {
    "Server": "",
    "Database": "",
    "IntegratedAuth": true,
    "Login": "",
    "Password": "",
    "ConnectTimeout": 0,
    "EnablePooling": true,
    "MaxPoolSize": 0,
    "ApplicationIntent": 0
  }
}

Default Values

The QueryStressSettings constructor initializes the following defaults:
PropertyDefault Value
ShareDbSettingstrue
MainQuery"" (empty string)
ParamQuery"" (empty string)
NumThreads1
NumIterations1
ConnectionTimeout15
CommandTimeout0 (unlimited)
EnableConnectionPoolingtrue
CollectIoStatstrue
CollectTimeStatstrue
ForceDataRetrievalfalse
KillQueriesOnCanceltrue
MaxPoolSizeNumThreads * 2

Build docs developers (and LLMs) love