Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher SQL Server CPU/RAM utilization SQL dialect queries not hitting SQL query cache #873

Closed
andreasohlund opened this issue Feb 17, 2022 · 0 comments · Fixed by #1254
Closed

Comments

@andreasohlund
Copy link
Member

andreasohlund commented Feb 17, 2022

Symptoms

Not specifying the size of the parameters forces the execution engine to convert parameters to the max size specified in the column definition. This increases CPU usage on the database server.

While this should apply to all commands issued by persister we have a user report specifically for the outbox inserts https://discuss.particular.net/t/nservicebus-inefficient-sql-with-persistence/2945

Who's affected

SQL Dialect users (Microsoft SQL Server, Azure SQL, and other hosted Microsoft SQL instance types)

Root cause

The SQL query cache is not used which results in SQL Server to create a new execution plan for every a lot of queries where the param length differs.

@andreasohlund andreasohlund changed the title Not specifying parameter size for commands prevent query plan cache usage Not specifying parameter size for commands force type conversion which results in higher database CPU usage Feb 17, 2022
@ramonsmits ramonsmits changed the title Not specifying parameter size for commands force type conversion which results in higher database CPU usage Higher SQL Server CPU/RAM utilization SQL dialect queries not hitting SQL query cache Oct 24, 2023
@ramonsmits ramonsmits added the Bug label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants