Overview
When you execute queries in SSMS, SQL Server applies a specific set of session-level settings. These settings affect query compilation, execution plans, and behavior. SQL Query Stress replicates these settings to ensure your stress tests produce the same results as production queries.Default SSMS-Compatible Settings
SQL Query Stress reads connection settings from thequerysettings.sql file located in the application directory. By default, the following settings are applied to every connection:
querysettings.sql
Why These Settings Matter
Query Plan Selection
Some settings affect which execution plan SQL Server chooses: ARITHABORT: When ON, queries may use different indexes. This setting particularly affects indexed views and computed columns.NULL comparisons work:
SET ANSI_NULLS ON:NULL = NULLreturnsNULL(ANSI standard)SET ANSI_NULLS OFF:NULL = NULLreturnsTRUE(legacy behavior)
Index Usage
Indexes on computed columns and persisted computed columns require specific settings:String Behavior
QUOTED_IDENTIFIER: Controls how double quotes are interpreted:SET QUOTED_IDENTIFIER ON: Double quotes delimit identifiers (column/table names)SET QUOTED_IDENTIFIER OFF: Double quotes delimit strings
How Settings Are Applied
Settings are applied automatically through the ConnectionSettingsHelper class:querysettings.sql are executed before your test query runs.
Customizing Connection Settings
Modifying querysettings.sql
You can customize connection settings by editing thequerysettings.sql file in the application directory:
Locate the File
Find
querysettings.sql in the same folder as the SQL Query Stress executable:- Windows GUI: Same folder as
SQLQueryStress.exe - CLI tool: Same folder as
sqlstresscmdorsqlstresscmd.exe
Edit with Text Editor
Open the file in any text editor. The file contains standard T-SQL
SET commands.Common Customizations
Suppress Row Count Messages
Prevent “(X row(s) affected)” messages:Enable Additional Statistics
Capture more detailed metrics:SQL Query Stress already collects I/O and time statistics when enabled in Options. Adding
SET STATISTICS IO ON here provides the same data.Change Transaction Isolation Level
Test with different isolation levels:Enable XACT_ABORT
Automatically roll back transactions on errors:Connection String Properties
In addition to session settings fromquerysettings.sql, you can configure connection-level properties in the ConnectionInfo class:
Pooling Configuration
EnablePooling: Control connection pooling (default: true)- Reduces overhead of establishing connections
- Reflects real-world application behavior
- Can affect parameterization testing (cached query plans)
Timeout Settings
ConnectTimeout: Maximum seconds to wait when establishing a connection (default: 15)Application Intent
ApplicationIntent: Specify read-only vs. read-write intent (useful for Always On Availability Groups)Encryption Options
Encrypt: Control connection encryptionOptional: Encrypt if server supports it (default)Mandatory: Require encryptionStrict: Require encryption with full certificate validation
Additional Parameters
Add custom connection string parameters:Separate Settings for Parameter Queries
When using parameterization, you can configure separate connection settings for the parameter database:ShareDbSettings is true (default), both main and parameter queries use MainDbConnectionInfo.
Verifying Settings
To confirm which settings are active during your test:Check Current Settings
Add this to your test query temporarily:View Connection Properties
Query system views for connection information:Best Practices
Match Production Settings
Match Production Settings
Ensure your stress tests use the same settings as your production application:
- Check your application’s connection string and session settings
- Update
querysettings.sqlto match - Verify with
@@OPTIONSquery
Don't Modify Settings in Test Queries
Don't Modify Settings in Test Queries
Avoid including Settings in
SET commands in your test queries:querysettings.sql apply once per connection. Settings in queries apply every iteration, adding overhead.Test Connection Pooling Impact
Test Connection Pooling Impact
Run tests with pooling enabled and disabled to understand the impact:Pooling typically improves performance but can mask connection establishment issues.
Version Control querysettings.sql
Version Control querysettings.sql
If multiple people use SQL Query Stress on shared test servers, keep
querysettings.sql in version control:Troubleshooting
Error: Index Cannot Be Used
If SQL Server won’t use an index:- Check if the index was created with specific ANSI settings
- Verify
querysettings.sqlincludes those settings - Use
SET SHOWPLAN_ALL ONto see why the index isn’t used
Error: Identifier Cannot Be Bound
If column names aren’t recognized:- Check
QUOTED_IDENTIFIERsetting - Verify double quotes vs. square brackets in your query
Different Results Than SSMS
If results differ from SSMS:- Compare
@@OPTIONSbetween SQL Query Stress and SSMS - Check for differences in isolation level
- Verify
querysettings.sqlmatches SSMS defaults
Next Steps
Using the GUI
Learn about connection configuration in the GUI
Using the CLI
Configure connection settings in JSON files
Query Parameterization
Set up separate connections for parameter queries
Interpreting Results
Understand how settings affect performance metrics