עדי

619 views

Published on

Common Errors That Effect Performance (Adi Cohen, Naya-Tech)

There are a few common errors that have a negative effect on performance. In this session we will review some of them, see why they impact performance and provide alternative solutions. Among the issues we will cover are:

· Misunderstanding of the query plan when using procedures

· Query plan differences between procedures and ad-hoc batches

· The differences between a temporary table and a table variable

· And many more…

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
619
On SlideShare
0
From Embeds
0
Number of Embeds
116
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

עדי

  1. 1. NAYA TechnologiesCOMMON ERRORS THAT SLOW THE SERVER
  2. 2. TYPE OF ERRORS 1. Misunderstanding parameter sniffing 2. Using batches instead of procedures 3. Using wrong temporary objects 4. Using to long columns
  3. 3. WHAT IS PARAMETER SNIFING? • When SQL Server creates a query plan for a procedure, it uses the parameters’ values to create the proper query plan
  4. 4. MISUNDERSTANDING PARAMETER SNIFING • This behavior can lead to the fallowing problems: – Sometimes different values need different plans – The query plan is according to the values that were passed and not according to the values during runtime
  5. 5. Demo 1 • Parameter sniffing – Working with procedures that different value should use different plans. – Avoiding modifying procedure’s parameters during runtime.
  6. 6. Using batch instead of procedures
  7. 7. BATCH VS. PROCEDURE • Batch might have a different and none optimal query plan then a stored procedure. • Batches might bloat the cache memory.
  8. 8. DEMO 2• Demo 2 – Difference in query plan between batch and stored procedure – Procedure cache and stored procedures and batches
  9. 9. USING WRONG TEMPORARY OBJECTS • SQL Server has 2 types of objects that store temporary data: – Temporary tables – Table variables • The myth that table variable is better then temporary table because it exists only in memory and never written to the disk is not true
  10. 10. TABLE VARIABLE VS. TEMPORARY TABLE • Some of the differences between table variable and temporary table are: – Temporary tables have statistics. Table variables dont. The server will always treat the table variable as if it has exactly 1 row – Inserting data into temporary tables cause recompilation. Inserting data into table variables doesn’t cause recompilation.
  11. 11. Demo 3 • Table variables, temporary tables and query plans
  12. 12. Using to long columns • SQL Server can use varying length columns • For columns with varying length, the server users the actual data length + 2 extra bytes
  13. 13. Using to long columns • Many times DBA are using to big size limitations on varying size columns • Using to big maximum size for a column can lead to memory problems and sometimes to different query plans
  14. 14. Demo 4 • Influence of column’s maximum size on memory consumption and query plans

×