עדי

download עדי

If you can't read please download the document

description

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…

Transcript of עדי

  • 1. NAYA TechnologiesCOMMON ERRORS THAT SLOWTHE SERVER

2. TYPE OF ERRORS1. Misunderstanding parameter sniffing2. Using batches instead of procedures3. Using wrong temporary objects4. Using to long columns 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. 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. Demo 1 Parameter sniffing Working with procedures that different value should use different plans. Avoiding modifying procedures parameters during runtime. 6. Using batch instead of procedures 7. BATCH VS. PROCEDURE Batch might have a different and none optimalquery plan then a stored procedure. Batches might bloat the cache memory. 8. DEMO 2 Demo 2 Difference in query plan between batch and stored procedure Procedure cache and stored procedures and batches 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. 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 doesnt cause recompilation. 11. Demo 3 Table variables, temporary tables and queryplans 12. Using to long columns SQL Server can use varying length columns For columns with varying length, the serverusers the actual data length + 2 extra bytes 13. Using to long columns Many times DBA are using to big sizelimitations on varying size columns Using to big maximum size for a column canlead to memory problems and sometimesto different query plans 14. Demo 4 Influence of columns maximum size onmemory consumption and query plans