Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHECKPOINT DBCC DROPCLEANBUFFERS DBCC FREESYSTEMCACHE Store (sys.dm_os_memory_clerks) Database Pool ALL DBCC FREEPROCCACHE Pool Plan handle DBCC FLUSHPROCINDB.

Similar presentations


Presentation on theme: "CHECKPOINT DBCC DROPCLEANBUFFERS DBCC FREESYSTEMCACHE Store (sys.dm_os_memory_clerks) Database Pool ALL DBCC FREEPROCCACHE Pool Plan handle DBCC FLUSHPROCINDB."— Presentation transcript:

1

2 CHECKPOINT DBCC DROPCLEANBUFFERS DBCC FREESYSTEMCACHE Store (sys.dm_os_memory_clerks) Database Pool ALL DBCC FREEPROCCACHE Pool Plan handle DBCC FLUSHPROCINDB DB_ID

3 Mock up or real data Baseline Multiple runs SSMS SET STATISTICS IO ON Logical vs physical reads SET STATISTICS TIME ON Graphical execution plan Missing index hint DMVs sys.dm_os_wait_stats sys.dm_exec_query_stats sys.dm_exec_procedure_stats

4 Fat arrows Operators Table scans Lookups Hash joins in OLTP workload Joins on non-selective columns Sort & sort warnings Parallelism Implicit conversions Estimates vs actual values Stale statistics Parameter sniffing UDFs Complicated predicates

5 Row-by-agonizing-row (RBAR) Could be useful: Running totals Calling SPs Administrative tasks Default settings: global, scrollable, writeable, dynamic Use LOCAL FAST_FORWARD sp_MSForEachDB is dangerous!

6 NULLS are neither equal nor different NOT IN on columns with NULLS will return incorrect data Large IN lists are a performance problem EXCEPT eliminates dups sort Anti semi join Personally, Id always prefer (NOT) EXISTS

7 Indexes Large inserts – disable indexes first Consider the whole workload, not just SELECTs Referential integrity Cascades Triggers and rollback from trigger Use CTEs to minimize human errors

8 SPs are not faster than ad hoc, but… Security is a plus Easier maintenance and tuning Parameterization Greater chance of plan reuse Parameter sniffing problem Recompilation SET NOCOUNT ON

9 Freely combined search conditions Static code for every combination Maintenance nightmare Static code with WHERE (col IS NULL) Performance issues, recompilation Dynamic SQL with sp_executesql Plan reuse Strongly-typed parameters Injection

10 Order of predicates matters Table variables are stored differently from #tables COALESCE is better than ISNULL UDF are good Adding hints makes it run faster


Download ppt "CHECKPOINT DBCC DROPCLEANBUFFERS DBCC FREESYSTEMCACHE Store (sys.dm_os_memory_clerks) Database Pool ALL DBCC FREEPROCCACHE Pool Plan handle DBCC FLUSHPROCINDB."

Similar presentations


Ads by Google