-
Notifications
You must be signed in to change notification settings - Fork 128
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
Fix Performance Issue for filtering on varchar columns in MS_SQL database #2052
Fix Performance Issue for filtering on varchar columns in MS_SQL database #2052
Conversation
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
Based on your screenshots, it seems like "varchar" variant had the perf boost:
Question about:
why cast instead of setting the sqldbtype on the dbconnectionparameter that is created? |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last question about tests.
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, the performance increases here are awesome! Just had a couple clarifying questions, a suggestion for some potential comment.
Why make this change?
What is this change?
We are modifying the DbCommand and adding extra information that is sent to SqlClient.
We introduced a new property called
SqlDbType
, By Default for String DbType, SqlDbType was considered asnvarchar
. now we are updating this property to the correct sql type.This allows db to directly execute the command without type casting due to type mismatch.
Carved out the code which creates DbCommand in
QueryExecuter
, and added an override method inMsSqlQueryExecuter
. here we set the property SqlDbType for the Parameters.How was this tested?
The performance difference is more visible when there are large number of rows. So, I added 20 million records and ran perf test.
Below are the performance results with avg response time:
BEFORE CHANGE
GRAPHQL
VARCHAR
NVARCHAR
REST
VARCHAR
NVARCHAR
AFTER CHANGE
GRAPHQL
VARCHAR
NVARCHAR
REST
VARCHAR
NVARCHAR