Performance tuning - NO.1 process (in process)

 

(1) Clean all the cache

CHECKPOINT
GO

DBCC DROPCLEANBUFFERS  

DBCC FREEPROCCACHE

 

 

http://stackoverflow.com/questions/382122/can-someone-explain-dbcc-dropcleanbuffers

CHECKPOINT flushes modified data pages to disk:

[CHECKPOINT] Writes all dirty pages for the current database to disk . Dirty pages are data pages that have been entered into the buffer cache and modified, but not yet written to disk. Checkpoints save time during a later recovery by creating a point at which all dirty pages are guaranteed to have been written to disk.

DBCC DROPCLEANBUFFERS then removes any non dirty (iow, clean) pages :

Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server.

To drop clean buffers from the buffer pool, first use CHECKPOINT to produce a cold buffer cache. This forces all dirty pages for the current database to be written to disk and cleans the buffers. After you do this, you can issue DBCC DROPCLEANBUFFERS command to remove all buffers from the buffer pool.

The end result is that you're starting with nothing cached.

http://www.sql-server-performance.com/tips/dbcc_commands_p1.aspx

DBCC DROPCLEANBUFFERS : Use this command to remove all the data from SQL Server's data cache (buffer) between performance tests to ensure fair testing. Keep in mind that this command only removes clean buffers, not dirty buffers. Because of this, before running the DBCC DROPCLEANBUFFERS command, you may first want to run the CHECKPOINT command first. Running CHECKPOINT will write all dirty buffers to disk. And then when you run DBCC DROPCLEANBUFFERS, you can be assured that all data buffers are cleaned out, not just the clean ones.

 

IMPORTANT!!! - DO NOT RUN THEM IN PRODUCTION SERVER

 

 

 

(2) Use SQL Profiler / Scripts to capture the long or most cost  query

 

2.1 SQL Profiler

2.2 Script

 

 

http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!828.entry?sa=752922820

 

 

(3) Analyse the statistics - reads/writes

SET STATISTICS IO ON   

SET STATISTICS TIME ON

 


For each indenpent statement, what is the CPU time and eclaspe time?

For each indenpent statement, what are the reads/writes of tables?

 

(4) Use esimate execute plan to check any recommend indexes

 

Check estimate rows and actual rows see any big different?

Check the loop type : nested loop or hash table join or merge join is it correct ?


notes: the query should not be dynamic

 

 

 

 

(5) Use execute plan to check any 'Table Scan ' or 'Clustered Index Scan '

       notes: we should avoid that

 

 

 

(6) Use Database Engine Tuning Advisor to analyse the trace file (get it from #2 SQL Profiler)

       notes: the query should not be dynamic or inline query(meaning : code in c#....)

 

(7) sp_spaceused 'tablename'

 

 

(8) find out indexes space

SELECT name,used,*
FROM Sysindexes
WHERE id=object_id('tablename')  ;

 

(9) unused index

http://www.mssqltips.com/tip.asp?tip=1545

 

(10) clustered index is it correct?

 

- clustered index is in used in join or where-clause? if not, dont use that clustered index


(11) Have we use cover index???


(12) Check the execute plan


set what is the biggest cost.


(13) cache plan

  USE master
GO
SELECT UseCounts,RefCounts, Cacheobjtype, Objtype,
ISNULL(DB_NAME(dbid),'dbname') AS DatabaseName, TEXT AS SQL
FROM sys.dm_exec_cached_plans
CROSS APPLY sys.dm_exec_sql_text(plan_handle)
WHERE dbid=DB_ID('dbname')
ORDER BY dbid,usecounts DESC;
GO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值