You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/findings/SQLCodeDevelopment.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -483,18 +483,24 @@ WHILE EXISTS (SELECT * FROM #Person WHERE IsProcessedFlag = 0)
483
483
484
484
Use Temporary Tables and not Table Variables.
485
485
486
-
- There is optimization limitation like lack of statistics that very frequently lead to performance issues. The advice of "use table variables if you have less than NNN rows" is flawed. It might seem like temporary tables are performant, but they are not scalable with a couple more years of data.
486
+
- There is optimization limitations like lack of statistics that very frequently lead to performance issues. The advice of "use table variables if you have less than NNN rows" is flawed. It might seem like temporary tables are performant, but they are not scalable with a couple more years of data.
487
487
- There are two use cases for table variable and are infrequently called for.
488
488
1. Extremely highly called code where recompiles from temporary table activity is a problem
489
489
2. Audit scenarios when you need to keep data after a transaction is rolled back.
If your stored procedure has multiple parameters where any one (or more) number are parameters are optional, you have a dynamic search query.
616
622
617
-
If your query is moderately complex you should use `OPTION (RECOMPILE)`. If you query is complex you should build the query with dynamic SQL.
623
+
If your query is moderately complex you should use `OPTION (RECOMPILE)`. If your query is complex, you should build the query with dynamic SQL.
618
624
619
625
You will also know this based on the `WHERE` clause of the query. You will see `@ProductId IS NULL` or have parameters wrapped in an `ISNULL()`.
620
626
@@ -973,12 +979,10 @@ END CATCH; /* <-- semicolon goes at the end here */
973
979
974
980
---
975
981
976
-
<aname="100"/>
977
-
978
982
## Using a Non-SARGable Expression in a WHERE Clause
979
983
**Check Id:** 100 [Not implemented yet. Click here to add the issue if you want to develop and create a pull request.](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=Using+a+Non-SARGable+Expression+in+a+WHERE+Clause)
980
984
981
-
Search ARGument..able. Avoid having a column or variable used within an expression or used as a function parameter. Columns are best used its self on one side of the operator. You will get a table scan instead of a index seek which will hurt performance.
985
+
Search ARGument..able. Avoid having a column or variable used within an expression or used as a function parameter. You will get a table scan instead of an index seek which will hurt performance.
982
986
983
987

984
988
@@ -987,7 +991,7 @@ Another issue with non-sargable queries besides the forced table scan is SQL Ser
987
991
988
992
- See [Using Missing Indexes Recommendations](/SQL-Server-Development-Assessment/best-practices-and-potential-findings/sql-code-conventions#using-missing-indexes-recommendations)
989
993
990
-
By changed the WHERE clause to not use the YEAR() function and doing a bit more typing allows SQL Server to understand what you want it to do.
994
+
Changing the WHERE clause to not use the YEAR() function and doing a bit more typing allows SQL Server to understand what you want it to do.
991
995
992
996

0 commit comments