åé¡ã®å£°æ
ããŒã¿ããŒã¹ã¢ããªã±ãŒã·ã§ã³ã䜿çšããéã®ããã«ããã¯ãç¹å®ããŸãã SQLã¯ãšãªã®ããã©ãŒãã³ã¹ã«é¢ããã¬ããŒãã®ã³ã³ãã€ã«ããšã©ãŒãšãããããã¯ã®åæãæ¯èŒã¬ããŒãã®ã³ã³ãã€ã«ããã¹ãã«ããã¹ãã¢ãããã·ãŒãžã£ã®ã«ãã¬ããžã®çšåºŠã®èšç®ãããã³ãã€ã¢ã°ã©ã ã®æ§ç¯ã
ãã¹ãã¯å®æçã«å®æœãããŸãã ãããã£ãŠãã¬ããŒãã¯èªåçã«çæãããæšæºåãããçžäºã«ç°¡åã«æ¯èŒãããå¿ èŠããããŸãã
䜿çšãããæè¡ïŒ
- Microsoft SQL Server
- Microsoft Office Excel
- SQLProfilerReportHelperãããžã§ã¯ãã§ç·šæãããäžé£ã®SQLã¯ãšãªã
- SQLã¯ãšãªãå®è¡ããæ©èœãåããããŒããã¹ãããŒã«ïŒ JMeter ã Visual Studio Ultimate ã...ïŒ;
ã¬ãã«300 ïŒå°é家åãïŒã
ã€ãŸããå®æãããã©ãã¯ã§ã¬ããŒããçæããæé ã¯æ¬¡ã®ãšããã§ãã
- SQLProfilerReportHelperãå®è¡ãããã¿ã³ãã¯ãªãã¯ããŸãã
- ã¬ããŒãããŒãã«ããã¬ã³ãŒããéžæããçµæãã¯ãªããããŒãã«ã³ããŒããŸãã
- Microsoft Office Excelãå®è¡ãããããã¡ãããšã³ããªãèªåçã«ãã©ãŒããããããããŒãã«ã«è²Œãä»ããŠãã¬ããŒãããã¥ã¡ã³ããä¿åããŸãã
SQLProfilerReportHelperãããŠã³ããŒããããšãããŒã«ãšã¬ããŒããã³ãã¬ãŒããå©çšã§ããŸãã
ããŒã«ãšã¬ããŒãã®èª¬æãããã³ããããã³ã³ãã€ã«ããæé ãèªã¿ããå Žåã¯ãå ã«é²ãã§ãã ããã
2ã€ã®äž»èŠãªã¬ããŒãã«ã€ããŠèª¬æããŸãã
- ã¹ãã¢ãããã·ãŒãžã£ã®ããã©ãŒãã³ã¹ã«é¢ããçµ±èšïŒãã©ããã¬ããŒãïŒ;
- ãã¹ãŠã®ãªã¯ãšã¹ãã®çµ±èšïŒè©³çŽ°ã¬ããŒãïŒã
1.ãã¬ãŒã¹
ããã»ã¹ã¯çµäºããããšã§ç解ã§ããŸããã ç解ã¯ããã»ã¹ãšãšãã«åãããã®æµããšèåããæµãã䌎ããªããã°ãªããŸããã
-ãã©ã³ã¯ã»ããŒããŒãã®å°èª¬ããã¥ãŒã³ããã
çµæãèªåçã«åæããããã¬ãŒã¹ã¯ãç¹å®ã®ã€ãã³ããšåã®ååšã瀺åããŸãã è² è·ãã¹ãã®éå§æã«äŸ¿å©ãªãœãããŠã§ã¢ã®èµ·åã ç§ã¯ãã®æ¹æ³ã䜿çšããŸãããä»ã®ãªãã·ã§ã³ãå¯èœã§ãã
ããŒããããOLTPã·ã¹ãã ããããã¡ã€ãªã³ã°ãããšãã¯ããã¬ãŒã¹ããã¡ã€ã«ã«ä¿åããããšããå§ãããŸãã ãã¹ãåŸã«ããŒã¿ããŒã¹ããŒãã«ã«ãã¬ãŒã¹ãã¡ã€ã«ãããŒãããã ããã«ãããããŒã¿ããŒã¹ã«ãã¬ãŒã¹ãæžã蟌ããšããããSQL Serverã®è¿œå è² è·ãå°ãªããªããŸãïŒæž¬å®ãããªãã£ãéã¯ã©ãã ãå°ãªããªããŸããïŒã ãŸããæ¶è²»ãããã¹ããŒã¹ãå°ãªããªããŸãïŒãã¬ãŒã¹ãã¡ã€ã«ã¯ãåæ§ã®ãã¬ãŒã¹ããŒãã«ããã3.9ã4åå°ãããªããŸãïŒã ããã«ãOLTPããã¹ããããè² è·ãã¹ããè¡ââãããŠãããšæ³å®ãããŠããŸãã
OLAPã·ã¹ãã ããããã¡ã€ãªã³ã°ãããšããè² è·ãäœããšããããŒã¿ããŒã¹ã«ãã¬ãŒã¹ãçŽæ¥èšé²ã§ããŸãã
1.1ã ãªãŒãã¹ã¿ãŒã
è² è·ãã¹ãã®éå§æã«ãããã¡ã€ãªã³ã°ãéå§ãããšäŸ¿å©ã§ãã è² è·ãã¹ãã®ã³ã³ããã¹ãã§ãè² è·ãã¹ãã³ãŒããå€æŽããã«å€ãå€æŽããã®ã«äŸ¿å©ãªãã©ã¡ãŒã¿ãŒã決å®ããŸãã
- useSQLProfiling ïŒtrue / falseïŒ-ãã¹ãã®éå§æã«ãã¬ãŒã¹ã䜿çšããŸãïŒããšãã°ãtrueïŒ
- pathSQLPrifiling-ãã¬ãŒã¹ãã¡ã€ã«ãä¿åããããã®Microsoft SQL ServerãåãããµãŒããŒäžã®ãã£ã¬ã¯ããªãžã®ãã¹ïŒããšãã°ãDïŒ\ Traces \ Synerdocs \ïŒ
- ããŒã¿ããŒã¹åïŒ4ã€ã®ãã©ã¡ãŒã¿ãŒïŒ-ãããã¡ã€ã«ãããã€ãã³ãïŒ tempdbããã³ãã¹ããããã·ã¹ãã ã®3ã€ã®ããŒã¿ããŒã¹ïŒã®ãã£ã«ã¿ãŒã«äœ¿çšããŸã
è² è·ãããã¡ã€ã«ã®ååã¯ããã¬ãŒã¹ãã¡ã€ã«ã®ååã«åæ ãããè² è·ãã¹ãã®ã³ã³ããã¹ããããæœåºãããŸãã ãããŠãè² è·ãããã¡ã€ã«ã¯ããã¹ãã®ç¶ç¶æéãååŸããŠããã¬ãŒã¹ããã€å®äºããããèšç®ããŸãã
ãã©ã¡ãŒã¿ãŒåãããã¯ãšãªScript.01.Start trace.sqlãå®è¡ãããŸã ïŒãããžã§ã¯ããã©ã«ããŒãŸãã¯äžã®ããã¯ã¹ã«ããscript \ start trace \ãã£ã¬ã¯ããªãåç §ïŒã
Script.01.trace.sqlãéå§ããŸã
-- Script.01.Start trace.sql -- : -- @traceDuration, Int, " ( )" -- , . -- @fileName, nvarchar(256), " " -- , . -- D:\Traces\Synerdocs\ServiceLoadTestBigFiles.2014.01.21 08.30.10 -- @db1, nvarchar(256), -- @db2, nvarchar(256), -- @db3, nvarchar(256), -- @db4, nvarchar(256), -- Create a Queue declare @rc int declare @TraceID int declare @maxfilesize bigint declare @stopTraceTime datetime declare @traceFileName nvarchar(256) declare @traceOptions int -- Create 100 MBytes files set @maxfilesize = 100 -- Duration of trace set @stopTraceTime = DATEADD(second, @traceDuration, SYSDATETIME()) -- Trace filename set @traceFileName = @fileName -- TRACE_FILE_ROLLOVER set @traceOptions = 2 exec @rc = sp_trace_create @TraceID output, @traceOptions, @traceFileName, @maxfilesize, @stopTraceTime if (@rc != 0) goto error -- Set the events declare @on bit set @on = 1 -- 162. User Error Message. Displays error messages that users see in the case of an error or exception. exec sp_trace_setevent @TraceID, 162, 1, @on -- TextData. ntext. exec sp_trace_setevent @TraceID, 162, 4, @on -- TransactionID. bigint. exec sp_trace_setevent @TraceID, 162, 9, @on -- ClientProcessID. int. exec sp_trace_setevent @TraceID, 162, 10, @on -- ApplicationName. nvarchar. exec sp_trace_setevent @TraceID, 162, 11, @on -- LoginName. nvarchar. exec sp_trace_setevent @TraceID, 162, 12, @on -- SPID. int. exec sp_trace_setevent @TraceID, 162, 20, @on -- Severity. exec sp_trace_setevent @TraceID, 162, 14, @on -- StartTime. datetime. exec sp_trace_setevent @TraceID, 162, 31, @on -- Error. int. exec sp_trace_setevent @TraceID, 162, 35, @on -- DatabaseName. nvarchar. exec sp_trace_setevent @TraceID, 162, 49, @on -- RequestID. int. exec sp_trace_setevent @TraceID, 162, 50, @on -- XactSequence. bigint. -- 148. Deadlock Graph. Occurs when an attempt to acquire a lock is canceled because the attempt was part of a deadlock and was chosen as the deadlock victim. Provides an XML description of a deadlock. exec sp_trace_setevent @TraceID, 148, 1, @on -- TextData. ntext. exec sp_trace_setevent @TraceID, 148, 4, @on -- TransactionID. bigint. Not used. exec sp_trace_setevent @TraceID, 148, 11, @on -- LoginName. nvarchar. exec sp_trace_setevent @TraceID, 148, 12, @on -- SPID. int. exec sp_trace_setevent @TraceID, 148, 14, @on -- StartTime. datetime. -- 10. RPC:Completed. Occurs when a remote procedure call (RPC) has completed. exec sp_trace_setevent @TraceID, 10, 1, @on -- TextData. ntext. exec sp_trace_setevent @TraceID, 10, 4, @on -- TransactionID. bigint. exec sp_trace_setevent @TraceID, 10, 9, @on -- ClientProcessID. int. exec sp_trace_setevent @TraceID, 10, 10, @on -- ApplicationName. nvarchar. exec sp_trace_setevent @TraceID, 10, 11, @on -- LoginName. nvarchar. exec sp_trace_setevent @TraceID, 10, 12, @on -- SPID. int. exec sp_trace_setevent @TraceID, 10, 13, @on -- Duration. bigint. exec sp_trace_setevent @TraceID, 10, 14, @on -- StartTime. datetime. exec sp_trace_setevent @TraceID, 10, 15, @on -- EndTime. datetime. exec sp_trace_setevent @TraceID, 10, 16, @on -- Reads. bigint. exec sp_trace_setevent @TraceID, 10, 17, @on -- Writes. bigint. exec sp_trace_setevent @TraceID, 10, 18, @on -- CPU. int. exec sp_trace_setevent @TraceID, 10, 31, @on -- Error. int. exec sp_trace_setevent @TraceID, 10, 34, @on -- ObjectName. nvarchar. exec sp_trace_setevent @TraceID, 10, 35, @on -- DatabaseName. nvarchar. exec sp_trace_setevent @TraceID, 10, 48, @on -- RowCounts. bigint. exec sp_trace_setevent @TraceID, 10, 49, @on -- RequestID. int. exec sp_trace_setevent @TraceID, 10, 50, @on -- XactSequence. bigint. -- 12. SQL:BatchCompleted. Occurs when a Transact-SQL batch has completed. exec sp_trace_setevent @TraceID, 12, 1, @on -- TextData. ntext. exec sp_trace_setevent @TraceID, 12, 4, @on -- TransactionID. bigint. exec sp_trace_setevent @TraceID, 12, 9, @on -- ClientProcessID. int. exec sp_trace_setevent @TraceID, 12, 11, @on -- LoginName. nvarchar. exec sp_trace_setevent @TraceID, 12, 10, @on -- ApplicationName. nvarchar. exec sp_trace_setevent @TraceID, 12, 12, @on -- SPID. int. exec sp_trace_setevent @TraceID, 12, 13, @on -- Duration. bigint. exec sp_trace_setevent @TraceID, 12, 14, @on -- StartTime. datetime. exec sp_trace_setevent @TraceID, 12, 15, @on -- EndTime. datetime. exec sp_trace_setevent @TraceID, 12, 16, @on -- Reads. bigint. exec sp_trace_setevent @TraceID, 12, 17, @on -- Writes. bigint. exec sp_trace_setevent @TraceID, 12, 18, @on -- CPU. int. exec sp_trace_setevent @TraceID, 12, 31, @on -- Error. int. exec sp_trace_setevent @TraceID, 12, 35, @on -- DatabaseName. nvarchar. exec sp_trace_setevent @TraceID, 12, 48, @on -- RowCounts. bigint. exec sp_trace_setevent @TraceID, 12, 49, @on -- RequestID. int. exec sp_trace_setevent @TraceID, 12, 50, @on -- XactSequence. bigint. -- Set the Filters exec sp_trace_setfilter @TraceID, 35, 0, 6, @db1 exec sp_trace_setfilter @TraceID, 35, 1, 6, @db2 exec sp_trace_setfilter @TraceID, 35, 1, 6, @db3 exec sp_trace_setfilter @TraceID, 35, 1, 6, @db4 -- Set the trace status to start exec sp_trace_setstatus @TraceID, 1 -- display trace id for future references select TraceID=@TraceID goto finish error: select ErrorCode=@rc finish:
æ»ãå€ïŒ
- TraceIDãintããã¬ãŒã¹ã»ãã·ã§ã³IDããã®åŸã®ãã¬ãŒã¹ã®åæ¢ã«åœ¹ç«ã¡ãŸãã
- ErrorCodeãintããã¬ãŒã¹ãéå§ãããªãã£ãå Žåã®ãšã©ãŒã³ãŒããsp_trace_createã®æ»ãã³ãŒãå€ãåç §ããŠãã ããã
ããŒããã¹ãã€ãã³ãã§ã®ã¯ãšãªã®å®è¡æ¹æ³ã¯ããã¹ãããŒã«ãšéçºèšèªã«ãã£ãŠç°ãªããŸãã JavaãšCïŒã®äž¡æ¹ã§ãããã¯åçŽã«è¡ãããŸãã å¥ã®ã¬ã€ããäœæã§ããŸãã 2ã€ã®æã®ããã€ãã®æ©èœïŒ
- ã€ãã³ãã¯ããŒããšãŒãžã§ã³ãã§å®è¡ãããŸããè€æ°ã®ããŒããšãŒãžã§ã³ããããå ŽåãããŒããã¹ãã®ãã©ã¡ãŒã¿ãŒã¯ãããã¡ã€ãªã³ã°ãæ©æã«éå§ããã³çµäºãããšãŒãžã§ã³ãã®ååãæå®ãããšãŒãžã§ã³ãã¯ãã®ç®çãååã§åŠç¿ããŸãã
- SQL ServerãDMZã®èåŸã«ããå Žåã SQL Serverã§åäœãããšãŒãžã§ã³ãã¯ãšããžãµãŒããŒã«ã€ã³ã¹ããŒã«ããããšãŒãžã§ã³ãã«ã¯ãŒãè² è·ãããã¡ã€ã«ãå²ãåœãŠãããŸãããããŒããã³ãã§DMZã䜿çšããªãæ¹ãç°¡åã§ãã
ã¹ãã¬ã¹ãã¹ãã«ç²Ÿéããå°é家ã¯ãåã®2ã€ã®æãç解ããŸãã ç解ã§ããªãå Žåã¯ããšãŒãžã§ã³ããDMZããªãããåèªåããã³æåã¢ãŒãã§ãã¬ãŒã¹ãéå§ããæ¹ãç°¡åã§ãã
1.1.1ã ãã¬ãŒã¹ãåæ¢
ãã¬ãŒã¹ã¯æééãã«å®è¡ãããŸãã ãã¬ãŒã¹ã®å®äºã®ç¬éã¯ããã¹ãã®æéïŒ traceDurationãã©ã¡ãŒã¿ãŒïŒã«ãã£ãŠæ±ºå®ããã Script.01.Start trace.sqlã¹ã¯ãªããã§èšç®ãããŸãã ã¹ãã¬ã¹ãã¹ããæééãã«å®è¡ãããããã°ã©ã ã§ååŸã§ããæéããããšæ³å®ãããŸãã
1.1.2ã æ©æçµäº
Script.01.Start trace.sqlãå®è¡ããããšã TraceIdãè¿ãããŸãã ãã¹ããæ©æã«çµäºããå Žåã TraceIdå€ã¯ãã¹ãçµäºã€ãã³ãã§ã¹ã¯ãªããã«æž¡ãããŸãã
-- Stops the specified trace. EXEC sp_trace_setstatus @traceid = @traceid , @status = 0 -- Closes the specified trace and deletes its definition from the server. EXEC sp_trace_setstatus @traceid = @traceid , @status = 2
1.2ã åèªåã¹ã¿ãŒã
ãã¹ãã®éå§æã«sqlã¯ãšãªãèªåçã«å®è¡ã§ããªãå Žåã¯ã Script.01.Start trace.sqlã¯ãšãªãSQL Management Studioããæåã§å®è¡ããŠãã¹ã¯ãªãããã©ã¡ãŒã¿ãäºåã«æ±ºå®ããŠããããšãã§ããŸãã
ãã¬ãŒã¹ã®éå§æã«åæ¢æéãèšç®ã§ããªãå Žåã stopTraceTimeãã©ã¡ãŒã¿ãŒãsp_trace_createããã·ãŒãžã£ã«æž¡ãå¿ èŠã¯ãããŸããïŒScript.01.Start trace.sqlïŒ29ãåç §ïŒã
1.2.1ã ãã¬ãŒã¹ãåæ¢
ã¹ã¯ãªããïŒããšãã°ããã£ã¬ã¯ããªïŒDïŒ\ Traces \ Synerdocs \ïŒïŒããåæ¢ãããã¬ãŒã¹ã»ãã·ã§ã³ãéžæããŠããããã¡ã€ã«ãåæ¢ããããšãã§ããŸãã
-- Script.02.Stop trace.sql DECLARE @traceid INT SET @traceid = (SELECT TOP 1 [id] FROM sys.traces WHERE [path] LIKE 'D:\Traces\Synerdocs\%') IF @traceid IS NOT NULL BEGIN -- Stops the specified trace. EXEC sp_trace_setstatus @traceid = @traceid , @status = 0 -- Closes the specified trace and deletes its definition from the server. EXEC sp_trace_setstatus @traceid = @traceid , @status = 2 END SELECT * FROM sys.traces
-- Script.02.Stop trace.sql DECLARE @traceid INT SET @traceid = (SELECT TOP 1 [id] FROM sys.traces WHERE [path] LIKE 'D:\Traces\Synerdocs\%') IF @traceid IS NOT NULL BEGIN -- Stops the specified trace. EXEC sp_trace_setstatus @traceid = @traceid , @status = 0 -- Closes the specified trace and deletes its definition from the server. EXEC sp_trace_setstatus @traceid = @traceid , @status = 2 END SELECT * FROM sys.traces
1.3ã æåã¹ã¿ãŒã
Microsoft SQL Server Profilerã䜿çšãããšãå€æ°ã®ã€ãã³ããåéã§ããŸãã
sp_trace_setevent ïŒ http://msdn.microsoft.com/en-us/library/ms186265.aspx ïŒãåç §ããŠãã ãã ã
æãèå³æ·±ãã€ãã³ããšããŠããšã©ãŒãããã¯ãããã·ãŒãžã£ããã³ã¯ãšãªã®å®è¡ãåãäžããŸãã
IDïŒã€ãã³ãIDïŒ | ã€ãã³ãå | 説æïŒã€ãã³ãã®èª¬æïŒ |
---|---|---|
162 | ãŠãŒã¶ãŒãšã©ãŒã¡ãã»ãŒãž | ãšã©ãŒãŸãã¯äŸå€ã®å Žåã«ãŠãŒã¶ãŒã«è¡šç€ºããããšã©ãŒã¡ãã»ãŒãžã衚瀺ããŸã |
148 | ãããããã¯ã°ã©ã | è©Šè¡ããããããã¯ã®äžéšã§ããããããããã¯ã®ç ç²è ãšããŠéžæãããããã«ãããã¯ã®ååŸã®è©Šè¡ããã£ã³ã»ã«ããããšãã«çºçããŸãã |
10 | RPCïŒå®äº | ãªã¢ãŒãããã·ãŒãžã£ã³ãŒã«ïŒRPCïŒãå®äºãããšãã«çºçããŸãã |
12 | SQLïŒBatchCompleted | Transact-SQLããããå®äºãããšãã«çºçããŸãã |
éžæããã€ãã³ãã«ã¯ãæãèå³æ·±ãåããããŸãã
Columnid | åå | çš®é¡ | ééã | ãã㯠| æç¶ã | ãåãåãã |
---|---|---|---|---|---|---|
1 | ããã¹ãããŒã¿ | ntext | + | + | + | + |
13 | æé | ããã° | + | + | ||
14 | éå§æé | æ¥æ | + | + | + | + |
16 | èªã¿ãŸã | ããã° | + | + | ||
17 | æžããŸã | ããã° | + | + | ||
18 | CPU | int | + | + | ||
31 | ãšã©ãŒ | int | + | + | + | |
34 | ãªããžã§ã¯ãå | nvarchar | + | |||
35 | DatabaseName | nvarchar | + | + | + |
ãã¬ãŒã¹ã«è¿œå ã®åãå«ããŸãããããã¯ã¬ããŒãã§ã¯äœ¿çšãããŸããããæååæã«åœ¹ç«ã¡ãŸãã
Columnid | åå | çš®é¡ | ééã | ãã㯠| æç¶ã | ãåãåãã |
---|---|---|---|---|---|---|
4 | TransactionID | ããã° | + | + | + | + |
9 | ClientProcessID | int | + | + | + | |
10 | ApplicationName | nvarchar | + | + | + | |
11 | LoginName | nvarchar | + | + | + | + |
12 | SPID | int | + | + | + | + |
15 | çµäºæé | æ¥æ | + | + | ||
48 | è¡æ° | ããã° | + | + | ||
49 | RequestID | int | + | + | + | |
50 | Xactsequence | ããã° | + | + | + |
DatabaseName ïŒ ColumnID 35ïŒã«ãããã¬ãŒã¹ã®ãã£ã«ã¿ãªã³ã°ã¯ãéžæããSQL ServerããŒã¿ããŒã¹ã«å¯ŸããŠã®ã¿å®è¡ãããŸã ïŒãã¹ããµãŒããŒã§ã¯ãå€ãã®å Žåãå€ãã®ããŒã¿ããŒã¹ããããããå¿ èŠãªããŒã¿ããŒã¹ã®ã¿ãéžæããå¿ èŠããããŸãïŒã
- tempdb ;
- ãã¹ã察象ã®ã¢ããªã±ãŒã·ã§ã³ã®ããŒã¿ããŒã¹ã
ãã£ã«ã¿ãªã³ã°ãšã°ã«ãŒãåãLoginNameã«ãã£ãŠäŸ¿å©ã«å®è¡ãããŸã ã
ãã¬ãŒã¹ãæåã§å®è¡ããã®ã䟿å©ãªå Žåã Microsoft SQL Server Profilerã䜿çšãããšããããã¡ã€ãªã³ã°çµæãããã«è¡šç€ºã§ããŸãã
1.3.1ã æ§ææžã¿ãã©ã¡ãŒã¿ãŒãèªååã®ããã®ã¹ã¯ãªããã«å€æãã
ç°ãªãã€ãã³ããåããã£ã«ã¿ãŒã®ã»ãããããå Žåã ãŸãããã®ãããªäžé£ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠãã¬ãŒã¹ã®éå§ãèªååããå Žåã¯ã SQL Server Profilerã圹ç«ã¡ãŸãã
èªåãã¬ãŒã¹éå§ã®èšå®ïŒ
- Microsoft SQL Server Profilerãèµ·åããŸã ã
- ãããã¡ã€ã«ãããã€ãã³ããéžæãããããã¡ã€ã«ãããã€ãã³ãã®å±æ§ãéžæããŸãã
- ãã£ã«ã¿ãªã³ã°ãã©ã¡ãŒã¿ãŒãïŒ DatabaseNameãŸãã¯LoginName㧠ïŒèšå®ãããšã åãã£ã«ã¿ãŒ...ãã¿ã³ãã¯ãªãã¯ããŠãã©ã¡ãŒã¿ãŒãéããŸãã
- ã¡ãã¥ãŒé ç®ã ãã¡ã€ã«/ãšã¯ã¹ããŒã/ã¹ã¯ãªãããã¬ãŒã¹å®çŸ©/ For SQL Server 2005-2008 R2 ... ãã䜿çšããŠãããã¬ãŒã¹ããããã£ããŠã£ã³ããŠã®ã€ãã³ãéžæã¿ãã§æå®ããããã¬ãŒã¹ãã©ã¡ãŒã¿ãŒãä¿åããŸãã
ããã«ãããã¹ã¯ãªãããæºåãããŸãã ã¹ã¯ãªããããã¹ãã«é¡äŒŒïŒ
ãããã¡ã€ãªã³ã°èšå®ã§çæãããã¹ã¯ãªãã
/****************************************************/ /* Created by: SQL Server 2008 R2 Profiler */ /* Date: 21/01/2014 10:23:02 */ /****************************************************/ -- Create a Queue declare @rc int declare @TraceID int declare @maxfilesize bigint set @maxfilesize = 5 -- Please replace the text InsertFileNameHere, with an appropriate -- filename prefixed by a path, eg, c:\MyFolder\MyTrace. The .trc extension -- will be appended to the filename automatically. If you are writing from -- remote server to local drive, please use UNC path and make sure server has -- write access to your network share exec @rc = sp_trace_create @TraceID output, 0, N'InsertFileNameHere', @maxfilesize, NULL if (@rc != 0) goto error -- Client side File and Table cannot be scripted -- Set the events declare @on bit set @on = 1 exec sp_trace_setevent @TraceID, 162, 31, @on exec sp_trace_setevent @TraceID, 162, 1, @on exec sp_trace_setevent @TraceID, 162, 9, @on exec sp_trace_setevent @TraceID, 162, 49, @on exec sp_trace_setevent @TraceID, 162, 10, @on exec sp_trace_setevent @TraceID, 162, 14, @on exec sp_trace_setevent @TraceID, 162, 50, @on exec sp_trace_setevent @TraceID, 162, 11, @on exec sp_trace_setevent @TraceID, 162, 35, @on exec sp_trace_setevent @TraceID, 162, 4, @on exec sp_trace_setevent @TraceID, 162, 12, @on exec sp_trace_setevent @TraceID, 162, 20, @on exec sp_trace_setevent @TraceID, 148, 11, @on exec sp_trace_setevent @TraceID, 148, 4, @on exec sp_trace_setevent @TraceID, 148, 12, @on exec sp_trace_setevent @TraceID, 148, 14, @on exec sp_trace_setevent @TraceID, 148, 1, @on exec sp_trace_setevent @TraceID, 10, 15, @on exec sp_trace_setevent @TraceID, 10, 31, @on exec sp_trace_setevent @TraceID, 10, 16, @on exec sp_trace_setevent @TraceID, 10, 48, @on exec sp_trace_setevent @TraceID, 10, 1, @on exec sp_trace_setevent @TraceID, 10, 9, @on exec sp_trace_setevent @TraceID, 10, 17, @on exec sp_trace_setevent @TraceID, 10, 49, @on exec sp_trace_setevent @TraceID, 10, 10, @on exec sp_trace_setevent @TraceID, 10, 18, @on exec sp_trace_setevent @TraceID, 10, 34, @on exec sp_trace_setevent @TraceID, 10, 50, @on exec sp_trace_setevent @TraceID, 10, 11, @on exec sp_trace_setevent @TraceID, 10, 35, @on exec sp_trace_setevent @TraceID, 10, 4, @on exec sp_trace_setevent @TraceID, 10, 12, @on exec sp_trace_setevent @TraceID, 10, 13, @on exec sp_trace_setevent @TraceID, 10, 14, @on exec sp_trace_setevent @TraceID, 12, 15, @on exec sp_trace_setevent @TraceID, 12, 31, @on exec sp_trace_setevent @TraceID, 12, 16, @on exec sp_trace_setevent @TraceID, 12, 48, @on exec sp_trace_setevent @TraceID, 12, 1, @on exec sp_trace_setevent @TraceID, 12, 9, @on exec sp_trace_setevent @TraceID, 12, 17, @on exec sp_trace_setevent @TraceID, 12, 49, @on exec sp_trace_setevent @TraceID, 12, 10, @on exec sp_trace_setevent @TraceID, 12, 14, @on exec sp_trace_setevent @TraceID, 12, 18, @on exec sp_trace_setevent @TraceID, 12, 50, @on exec sp_trace_setevent @TraceID, 12, 11, @on exec sp_trace_setevent @TraceID, 12, 35, @on exec sp_trace_setevent @TraceID, 12, 4, @on exec sp_trace_setevent @TraceID, 12, 12, @on exec sp_trace_setevent @TraceID, 12, 13, @on -- Set the Filters declare @intfilter int declare @bigintfilter bigint exec sp_trace_setfilter @TraceID, 35, 0, 6, N'ServiceDB' exec sp_trace_setfilter @TraceID, 35, 1, 6, N'ClientDB' exec sp_trace_setfilter @TraceID, 35, 1, 6, N'LogsDB' exec sp_trace_setfilter @TraceID, 35, 1, 6, N'Tempdb' -- Set the trace status to start exec sp_trace_setstatus @TraceID, 1 -- display trace id for future references select TraceID=@TraceID goto finish error: select ErrorCode=@rc finish: go
[ãã¬ãŒã¹ããããã£]ãŠã£ã³ããŠã®[ å šè¬ ]ã¿ãã®ãã©ã¡ãŒã¿ãŒã¯ããã¬ãŒã¹ã¹ã¯ãªããã®æºåã«å«ãŸããŸããã ã¹ã¯ãªããã«æåã§è¿œå ãããå¿ èŠãªãã©ã¡ãŒã¿ãŒããããŸãã
- ãã¡ã€ã«ã«ä¿å ;
- æ倧ãã¡ã€ã«ãµã€ãºïŒMBïŒãèšå®ããŸã ã
- ãã¡ã€ã«ã®ããŒã«ãªãŒããŒãæå¹ã«ããŸã ã
- ãã¬ãŒã¹åæ¢æéãæå¹ã«ããŸã ã
ãã¡ã€ã«åãšãã¬ãŒã¹åæ¢æéã¯è² è·ãã¹ãã³ãŒãããèšå®ãããæ倧ãã¡ã€ã«ãµã€ãºãšæ°ãããã¡ã€ã«ãäœæããå¿ èŠããããšããèšå·ã¯ãå®æ°ã«ãã£ãŠäŸ¿å©ã«èšå®ãããŸãã Script.01.Start trace.sqlãäžèšã§äœæããããšããã§ãã
ãã©ã¡ãŒã¿ãŒã®èª¬ææ倧ãã¡ã€ã«ãµã€ãºïŒMBïŒãèšå®ã ã ãã¡ã€ã«ããŒã«ãªãŒããŒãæå¹ã«ããŸã ïŒ http : //msdn.microsoft.com/en-us/library/ms191206.aspx
ãã¬ãŒã¹ãã¡ã€ã«ãããŒã¿ããŒã¹ã«ã¢ããããŒããã
ã¬ããŒããçæããããã«ããã¬ãŒã¹ãã¡ã€ã«ãããŒã¿ããŒã¹ããŒãã«ã«ããŒããããŸãã
ããŒã¿ããŒã¹ãäºåã«äœæããããã¬ãŒã¹ããã®ããŒã¿ããŒã¹ã®ããŒãã«ã«ããŒããããã¬ããŒããå«ãããŒãã«ãäœæãããŸãã ããŒã¿ããŒã¹ã«ProfilerResultsãšããååãä»ããããšãã§ããŸãã ããŒã¿ããŒã¹åã«ã¯ããããžã§ã¯ãã®ååãåæ ãããšäŸ¿å©ã§ãããããžã§ã¯ãã®ã¬ããŒãã¯ããããžã§ã¯ãã«èç©ãããŸãã ç§ãåãçµãã§ãããããžã§ã¯ãã¯ãã€ãŠMidwayãšåŒã°ããŠãããããããŒã¿ããŒã¹ã¯MidwayProfilerResultsãšåŒã°ããŠããŸãã ã ããŒã¿ããŒã¹ãäœæããã«ã¯ã SQL Management Studioã䜿çšãããšäŸ¿å©ã§ããSQLManagement Studioã§ã¯ãããŒã¿ããŒã¹ãäœæããããã®ãŠã£ã¶ãŒãããããæ°åã¯ãªãã¯ããã ãã§å®äºã§ãã
ã·ã¹ãã é¢æ°fn_trace_gettableãããŒãã«äœ¿çšãããŸãã
use "ProfilerResults" SELECT "EventClass" , "TextData" , "Duration" , "StartTime" , "Reads" , "Writes" , "CPU" , "Error" , "ObjectName" , "DatabaseName" , "TransactionID" , "ClientProcessID" , "ApplicationName" , "LogiName" , "SPID" , "EndTime" , "RowCounts" , "RequestID" , "XactSequence" INTO "SOAP.v2.3.1.5577" FROM ::fn_trace_gettable(N'D:\Traces\Synerdocs\LoadTest.SOAP.Trace.StartOn 2013.01.21 08.30.00.trc', default)
fn_trace_gettableãã©ã¡ãŒã¿ãŒã¯ãæåã®ãã¬ãŒã¹ãã¡ã€ã«ãžã®ãã¹ãæå®ãã2çªç®ã®ããã©ã«ããã©ã¡ãŒã¿ãŒã¯ãåããã¬ãŒã¹ã»ãã·ã§ã³ããã®ãã¹ãŠã®ãã¡ã€ã«ãããŒãã«ã«ããŒããããããšãæå³ããŸãïŒãµã€ãºã100 MBã®æå®ãã¡ã€ã«ã ãã§ãªãïŒã
ãããã¡ã€ãªã³ã°ããŒãã«ã®ååã¯ããã¹ã察象ã®ã·ã¹ãã ã®ããŒãžã§ã³ãšè² è·ãããã¡ã€ã«ãåæ ããããã«èšå®ãããŸãïŒäŸïŒãSOAP.v2.3.1.5577ãïŒã ã¬ããŒãä»ãã§äœæãããããŒãã«ã«ã¯ããããã圢æãããããã¡ã€ãªã³ã°ããŒãã«ã®ååãååã«å«ãŸããŸãã å°æ¥ãå€ãã®ã¬ããŒãã®äžã§ç®çã®ããŒãã«ãèŠã€ããã«ã¯ãããŒãã«ã«æå³ã®ããååãèšå®ããããšããå§ãããŸãã
ããŒããŠã§ã¢ã«ãã£ãŠã¯ãããŠã³ããŒãã«æéããããå ŽåããããŸãã 䜿çšãããµãŒããŒã§ã¯ãããŠã³ããŒãé床ã¯æ¬¡ã®ãšããã§ãã160ã190 MB /åãŸãã¯1.5-1åããã2ã€ã®ãã¬ãŒã¹ãã¡ã€ã«ïŒ1ã€ã®ãã¡ã€ã«-100 MBïŒã ãã¬ãŒã¹ãã¡ã€ã«ãããŒã¿ããŒã¹ã«ããŒãããæè¿ã®2ã€ã®æäœã®æž¬å®ïŒéåžžã®ããŒããããã¡ã€ã«ãšå€§ããªãã¡ã€ã«ã®ããŒããããã¡ã€ã«ïŒã
ãã¬ãŒã¹ãã¡ã€ã«ãµã€ãºïŒMBïŒ | ããŠã³ããŒãæéïŒhïŒminïŒsecïŒ | å¹³åããŠã³ããŒãé床ïŒMB /åïŒ | ãã¬ãŒã¹ããŒãã«ãµã€ãºïŒMBïŒ | è¡æ° | å¹³åããŒãã«è¡ãµã€ãºïŒKBïŒ | ããŒãã«ãžã®ããŒãåŸã®ãµã€ãºå¢å ç |
---|---|---|---|---|---|---|
7 598 | 00:45:17 | 168.8 | 29,478.3 | 766 370 | 39,4 | 3.9 |
67 062 | 05:46:32 | 193.8 | 268 875.7 | 2 861 599 | 96.2 | 4.0 |
2.æé ã®èŠçŽã¬ããŒãïŒRPCïŒå®äºïŒ-ããã©ããã¬ããŒãã
é床ã«åŸ¹åºçãªåæã¯çå®ãããããŸãã
-ãã©ã³ã¯ã»ããŒããŒãã®å°èª¬ãç äžã®ã¡ãµã€ã¢ãããã®å€ä»£ããªãŒãã³ã®çºèš
ããŒã¿ããŒã¹ã®æäœãäž»ã«ããŒã¿ããŒã¹APIïŒã¹ãã¢ãããã·ãŒãžã£ãšé¢æ°ã®ã»ããïŒãä»ããŠå®è¡ãããå Žåããã®ã¬ããŒãã¯æåã«äœæãããã®ã§ãã
ãã®ã¬ããŒãã¯ã RPCã®ã°ã«ãŒãåã§ãããã¬ãŒã¹ããŒãã«ããã®å®äºã€ãã³ãã¯ãããŒã¿ããŒã¹åïŒ DatabaseName ïŒããã³ä¿åãããããã»ã¹ãŸãã¯é¢æ°ã®ååïŒ ObjectName ïŒã§ãæãéãã¯ãšãªãšæãé ãã¯ãšãªã®çµ±èšãšããã¹ããå«ã¿ãŸã SQLçµ±èšïŒBatchCompletedãã¬ããŒãã«ãããŸãããããã¯1è¡ã®ã¿ã§ã-现ååãªãã®NULLè¡ã ãããã£ãŠããã®ã¬ããŒãã¯ããã©ããã¬ããŒãããšåŒã°ããŸãã
ãã©ããã¬ããŒãã®æ§ç¯ãèªååããã«ã¯ãè£å©ããŒã«Tools.SQLProfilerReportHelperã䜿çšãããŸãã
2.1ã ã¬ããŒãããã©ããã¬ããŒããã®äœæã®æºå
æºåã¯ã Tools.SQLProfilerReportHelperãã©ãŒã ã®ãã¿ã³ãæŒãããšã§ãã
- Tools.SQLProfilerReportHelperãèµ·åããŸã ã
- [ SQL Server]ãã£ãŒã«ããš[ ããŒã¿ããŒã¹]ãã£ãŒã«ãã«ã SQL Serverãšãããã¡ã€ãªã³ã°ããŒã¿ããŒã¹ã®ååãå ¥åããŸã ã äŸã§ã¯ããããã¯ãSQL ServerããšãProfilerResultsãã§ãã [ æ¥ç¶ ]ãã¿ã³ãã¯ãªãã¯ããŸãã SQL Serverã§WindowsèªèšŒã䜿çšããå ŽåããŠãŒã¶ãŒã¯ãããã¡ã€ãªã³ã°ããŒã¿ããŒã¹ã®ç®¡çè ã§ãªããã°ãªããŸããã
- [ ãããã¡ã€ãªã³ã°ããŒãã«]ãªã¹ããããããã¡ã€ãªã³ã°çµæãå«ãããŒãã«ãéžæããŸãã äŸã§ã¯ãããã¯ãTraceTable.v2.7.LoadProfile1.2010.10.10ãã§ãã
- ãããã¡ã€ãªã³ã°ããŒãã«ã«æ°ããTextKeyåãäœæããŸã-[ ãã§ã㯠]ãã¿ã³ãã¯ãªãã¯ããŠããŒãã«å ã®åã®æç¡ã確èªã ãåãååšããªãå ŽåïŒ[ äœæ ]ãã¿ã³ã䜿çšå¯èœã«ãªããŸãïŒã[ äœæ ]ãã¿ã³ãã¯ãªãã¯ããŸã ã
- ã¹ã¿ãŒããã¿ã³ãæŒããŸãïŒSP ã¯ãªãã¯ãããšã ObjectNameåããTextKeyåã«å€ãã³ããŒãããŸãã
ObjectNameãTextKeyåã«ã³ããŒããå ŽåãåŠçããã¬ã³ãŒãã®æ°ã ãããŠãæ®ãã®æäœæéãèšç®ãããŸãã StopïŒSPãã¿ã³ãæŒããšãããã»ã¹ãäžæã§ããŸãã
2.2ã ã¬ããŒãããã©ããã¬ããŒããã®äœæ
ã³ããŒãå®äºãããããã©ããã¬ããŒããäœæããŸãã ãããè¡ãã«ã¯ã[ ãã§ã㯠]ãã¿ã³ãã¯ãªãã¯ãïŒã¬ããŒãã®ããããŒãã«ã®æç¡ã確èªããŸãïŒãã¬ããŒãã®ããããŒãã«ããªãå Žåã¯ã[ äœæ ]ãã¯ãªãã¯ããŸã ã çµæãšããŠãååã«ãDraftStatãã®æ«å°Ÿãä»ããããŒãã«ãäœæãããŸãããã®äŸã§ã¯ã TraceTable.v2.7.LoadProfile1.2010.10.10.DraftStatã§ãã ããŒãã«ã®ãµã€ãºã¯æ¯èŒçå°ããïŒ10ã30 MBïŒã ãã®ããŒãã«ã¯ãã¹ãã¢ãããã·ãŒãžã£ãšé¢æ°ã®ããã©ãŒãã³ã¹ã«é¢ããçµ±èšã®é·æä¿åãç®çãšããŠããŸãã
ã¯ãšãªã«ãã£ãŠããŒãã«ã®å 容ãååŸããŸãã
USE "ProfilerResults" SELECT * FROM "dbo"."TraceTable.v2.7.LoadProfile1.2010.10.10.DraftStat"
ã¯ãšãªã¯ã SQL Management Studioã§äŸ¿å©ã«å®è¡ãããŸã ã
ã¯ãšãªããã¹ãTextData -....ãå«ãåãé€ããã¹ãŠã®åãã¯ãªããããŒãã«ã³ããŒããŸãã
DtaftStatããŒãã«ã®åã®æ§æïŒãã©ããã¬ããŒãïŒ
ã³ã©ã | çš®é¡ | 説æ |
---|---|---|
DatabaseName | nvarcharïŒ256ïŒ | ããŒã¿ããŒã¹ïŒã°ã«ãŒãåããŒïŒã |
ObjectName-ã㌠| nvarcharïŒ256ïŒ | ã¹ãã¢ãããã·ãŒãžã£ãŸãã¯é¢æ°ã®ååïŒã°ã«ãŒãåããŒïŒã |
å¹³åïŒCPUïŒ-ã㌠| int | ã€ãã³ãã§äœ¿çšãããããªç§åäœã®CPUæéïŒå¹³åïŒã |
avgïŒæéïŒ-key | ããã° | ã€ãã³ãã®æéïŒå¹³åïŒïŒããªç§ïŒã |
ïŒ ç¶ç¶æéã㌠| æµ®ã | ã€ãã³ãã®åèšæéã®å ±æïŒãœãŒãããŒïŒã |
avgïŒèªã¿åãïŒ-key | ããã° | ãµãŒããŒãã€ãã³ãã«å¯ŸããŠå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ïŒå¹³åïŒã |
ã«ãŠã³ãã㌠| int | åŒã³åºãïŒããŒã¹ïŒã®æ°ã |
ãªããžã§ã¯ãå | nvarcharïŒ256ïŒ | ã¹ãã¢ãããã·ãŒãžã£ãŸãã¯é¢æ°ã®ååïŒã°ã«ãŒãåããŒïŒã |
å¹³åïŒCPUïŒ | int | CPUåã®å¹³åå€ïŒã€ãã³ãã§äœ¿çšãããããªç§åäœã®å¹³åCPUæéïŒã |
æ倧ïŒCPUïŒ | int | ã€ãã³ãã§äœ¿çšãããããªç§åäœã®æ倧CPUæéã |
åèšïŒCPUïŒ | int | ã€ãã³ãã§äœ¿çšãããããªç§åäœã®åèšCPUæéã |
ïŒ CPU | æµ®ã | ã€ãã³ãã®åèšCPUæéã®ã·ã§ã¢ã |
åïŒæéïŒ | ããã° | ã€ãã³ãã®æéïŒããïŒããªç§ã |
å¹³åïŒæéïŒ | ããã° | ã€ãã³ãã®æéïŒå¹³åïŒïŒããªç§ïŒã |
maxïŒæéïŒ | ããã° | ã€ãã³ãã®æéïŒæ倧ïŒïŒããªç§ïŒã |
sumïŒæéïŒ | ããã° | ã€ãã³ãã®æéïŒåèšïŒïŒããªç§ïŒã |
ç¶ç¶æéã®å²å | æµ®ã | ã€ãã³ãã®åèšæéã®ã·ã§ã¢ã |
minïŒèªã¿åãïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ïŒæå°ïŒã |
å¹³åïŒèªã¿åãïŒ | ããã° | ãµãŒããŒãã€ãã³ãã«å¯ŸããŠå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ïŒå¹³åïŒã |
maxïŒèªã¿åãïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ïŒæ倧ïŒã |
sumïŒèªã¿åãïŒ | ããã° | ãµãŒããŒãã€ãã³ãã«å¯ŸããŠå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ïŒåèšïŒã |
èªã¿åãç | æµ®ã | ãµãŒããŒãã€ãã³ãã«å¯ŸããŠå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®å²åã |
minïŒæžã蟌ã¿ïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããã¬ã³ãŒããããã®ç©çãã£ã¹ã¯ã¢ã¯ã»ã¹æ°ïŒããïŒã |
avgïŒæžã蟌ã¿ïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããã¬ã³ãŒããããã®ç©çãã£ã¹ã¯ã¢ã¯ã»ã¹æ°ïŒå¹³åïŒã |
maxïŒæžã蟌ã¿ïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããã¬ã³ãŒããããã®ç©çãã£ã¹ã¯ã¢ã¯ã»ã¹æ°ïŒæ倧ïŒã |
sumïŒæžã蟌ã¿ïŒ | ããã° | ã€ãã³ãã«å¯ŸããŠãµãŒããŒãå®è¡ããã¬ã³ãŒãããšã®ç©çãã£ã¹ã¯ã¢ã¯ã»ã¹æ°ïŒåèšïŒã |
æžã蟌ã¿ç | æµ®ã | ã€ãã³ãã«å¯ŸããŠãµãŒããŒã«ãã£ãŠè¡ãããæžã蟌ã¿ããšã®ç©çãã£ã¹ã¯æžã蟌ã¿æ°ã®å²åã |
ã«ãŠã³ã | int | ã€ãã³ãã®æ°ã |
ïŒ ã«ãŠã³ã | æµ®ã | ã€ãã³ãã®æ°ã®å²åã |
TextData-minïŒæéïŒ | ntext | å®è¡æéãæå°ã®ã¯ãšãªããã¹ãã |
TextData-maxïŒæéïŒ | ntext | å®è¡æéãæ倧ã®ã¯ãšãªããã¹ãã |
TextData-minïŒèªã¿åãïŒ | ntext | ãµãŒããŒãå®è¡ããè«çãã£ã¹ã¯èªã¿åãã®æ°ãæå°éã®èŠæ±ããã¹ãã |
TextData-maxïŒèªã¿åãïŒ | ntext | ãµãŒããŒã«ãã£ãŠè¡ãããè«çèªã¿åãã®æ倧æ°ãæ倧ãšãªãã¯ãšãªããã¹ãã |
TextData-minïŒCPUïŒ | ntext | CPUæéãæå°ã®èŠæ±ããã¹ãã |
TextData-maxïŒCPUïŒ | ntext | CPUæéãæ倧ã®ãªã¯ãšã¹ãããã¹ãã |
TextData-minïŒæžã蟌ã¿ïŒ | ntext | ãµãŒããŒã«ãã£ãŠè¡ãããç©çãã£ã¹ã¯æžã蟌ã¿ã®æ°ãæå°ãšãªãèŠæ±ããã¹ãã |
TextData-maxïŒæžã蟌ã¿ïŒ | ntext | ãµãŒããŒã«ãã£ãŠè¡ãããç©çãã£ã¹ã¯æžã蟌ã¿ã®æ倧æ°ãæ倧å€ã«éããèŠæ±ããã¹ãã |
Microsoft Office Excelã§ã¬ããŒããã³ãã¬ãŒããéããŸã ïŒèªåã»ã«æžåŒèšå®ä»ãã®ããŒãã«-æªãå€ããè¯ãå€ãžã®å€ã®åŒ·èª¿è¡šç€ºïŒã ã¯ãªããããŒãã®å 容ãããã¥ã¡ã³ãã«è²Œãä»ããŸãã
ããã¥ã¡ã³ãã¯ã ïŒ Durationåã§éé ã§ãœãŒãããã倧ããªè²ä»ãã®ããŒãã«ã®ããã«èŠããŸãã
æåã®6åã¯æ®ãããåé¢ãããŠããïŒãããŠè€è£œãããŸãïŒãäž»ãªåã§ãã ãããã®6ã€ã®äž»èŠãªåã¯ã Excelããã¥ã¡ã³ãããWordããã¥ã¡ã³ãã«äŸ¿å©ã«ã³ããŒãããŸãã
ãNULLãããŒãšãsp_executesqlãããŒã®ããè¡ã¯ãã¯ãšãªåŒã³åºãïŒ SQLïŒBatchCompleted ïŒããã³ã¹ãã¢ãããã·ãŒãžã£sp_executesqlãåŒã³åºããŠå®è¡ãããã¯ãšãªã®çµ±èšã§ãã ãã®ãããªãªã¯ãšã¹ããå°ãªãïŒ ã«ãŠã³ãåïŒããã®å®è¡æéã®å²åãå°ããïŒ ïŒ æéåïŒå Žåã詳现ã¬ããŒããäœæã§ããããã©ããã¬ããŒãã®åæã«éå®ãããŸãã
2.3ã ãã©ããã¬ããŒãã®åæ
æ倧å€ãïŒ Durationããã³avgïŒReadsïŒã®ã¹ãã¢ãããã·ãŒãžã£ã«æ³šæããŠãã ããã
å€ãã®å Žåããããã®åŒã³åºãã¯ãæ¬ èœããŠããã€ã³ããã¯ã¹ãè¿œå ããããšã§é«éåã§ããŸãã SQL Management Studioã¯ãã©ã®ã€ã³ããã¯ã¹ãè¿œå ããã®ãæé©ããæããŠãããŸãã ã¢ããã€ã¹ã®æ£ç¢ºæ§ã¯çµ¶å¯Ÿçãªãã®ã§ã¯ãªããé«ããã®ã§ãã
ã¯ãšãªãæé©ã§ã€ã³ããã¯ã¹ãé©åã§ããå ŽåããããŸããããã¹ãã¢ãããã·ãŒãžã£ã®ããã¹ãã§ã¯ã倧ããªããŒãã«ã®ãã¹ãŠã®ã¬ã³ãŒããïŒãããã°çšã«ïŒéžæãããŸãã-ããã«ãããã¯ãšãªã¯ïŒ Durationã¬ããŒãã§å é ã«ç«ã¡ãŸããã SQL Management Studioã§ã¯ãšãªãå®è¡ãããšããã®ãããªèšå€§ãªéžæã®ã±ãŒã¹ãæããã«ãªããŸã ã ã¬ããŒãã«ãããšããã®ãããªç¬éãç¹å®ããããšã¯ã§ããŸãããã¬ããŒãã®RowCountåã«çµ±èšãå«ããŸããïŒãããå«ããå¿ èŠããããŸãïŒã
ïŒ DurationãšCountã®å€ã倧ããåŒã³åºãããã£ãã·ã¥ã§ããå ŽåããããšæããŸãïŒã¬ã³ãŒãã補åã® "ïŒ Duration" x "Count"ã®éé ã«äžŠã¹æ¿ããããšãã§ããŸãïŒã
ããããã ïŒ DurationãšavgïŒCPUïŒã®å€ã倧ããåŒã³åºãã§ã¯ãæååãæ°åŠãååž°ã®åŠçãæé©ã§ã¯ãããŸããã
ïŒ Durationããã³avgïŒWriteïŒã®å€ã倧ããåŒã³åºãã§ã¯ãäžæããŒãã«ãæé©ã«äœ¿çšã§ããªãå ŽåããããŸãã ãŸãã¯ãã€ã³ããã¯ã¹ãšè€éãªããªã¬ãŒãå€ãããããŒãã«ãžã®æ¿å ¥ãæããŸãã
æéãè«çèªã¿åãå€ãCPUæéã®æå°å€ãšæ倧å€ãå«ãã¯ãšãªããã¹ãã¯ãã¬ããŒãããŒãã«ã®åããæœåºãããŸãïŒã¬ããŒãããã¥ã¡ã³ãã«ã¯ãã®ãããªåã¯ãããŸããïŒã
- TextData-minïŒæéïŒ;
- TextData-maxïŒæéïŒ;
- TextData-minïŒèªã¿åãïŒ;
- TextData-maxïŒèªã¿åãïŒ;
- TextData-minïŒCPUïŒ;
- TextData-maxïŒCPUïŒ;
- TextData-minïŒæžã蟌ã¿ïŒ;
- TextData-maxïŒæžã蟌ã¿ïŒã
ããã¹ãã¯SQL Management Studioã§åæãããŸã ã
3.ã¯ãšãªã®æŠèŠã¬ããŒãïŒRPCïŒå®äº+ SQLïŒBatchCompletedïŒ-詳现ã¬ããŒã
ãã©ããã¬ããŒãã§ãããŒã "NULL"ããã³ "sp_executesql" ã®è¡ãå€ãã®ã¯ãšãªã®å®è¡è©³çŽ°ãé ããå Žåã 次ã«ã 詳现ã¬ããŒãã§ã°ã«ãŒãåãå¯èœãªéã詳现ã«å®è¡ãããŸãã
詳现ã¬ããŒãã®äœæã¯ã ãã©ããã¬ããŒãããã§ã«çæãããŠãããæºåã¢ã¯ã·ã§ã³ãå®äºããŠããããšãåæãšããŠããŸãã
3.1ã 詳现ã¬ããŒãäœæã®æºå
å Žåã¯å ±åæžæ¡ã圢æãããããã¯ããã®ã«ååã§ãïŒ
- Function PrepareTextDataã°ã«ãŒãã®Checkãã¿ã³ãã¯ãªãã¯ããŠãPrepareTextDataé¢æ°ãããŒã¿ããŒã¹å ã«ããããšã確èªããŸãïŒå¿ èŠã«å¿ããŠCreateãã¿ã³ãã¯ãªãã¯ããŠé¢æ°ãäœæããŸãïŒã
- CformirovatããŒïŒã°ã«ãŒãã»ã€ãã³ãã®ããã®ã¯ãšãªããã¹ãã®ã°ã«ãŒãåSQLïŒBatchCompletedåäžã®TextDataïŒãæŒããšãEtpuã¹ã¿ãŒãïŒSQLã
ãã以å€ã®å Žåã¯ãæåãããã¹ãŠãè¡ãå¿ èŠããããŸãããããã¡ã€ãªã³ã°ããŒãã«ã䜿çšããŠããŒã¿ããŒã¹ã«æ¥ç¶ãããããã¡ã€ãªã³ã°ããŒãã«ãéžæããTextKeyåãäœæãã[ éå§ïŒSP ]ãã¿ã³ãã¯ãªãã¯ããŠãã¹ãã¢ãããã·ãŒãžã£ã®ã°ã«ãŒãåããŒãå ¥åããŸããã¢ã¯ã·ã§ã³ã¯ãããŒã«ãã©ãŒã ã§äœ¿çšå¯èœãªãã¿ã³ãã¯ãªãã¯ããããšã§å®è¡ãããŸããæŒãå¿ èŠã®ãªããã¿ã³ã¯ã¢ã¯ã»ã¹ã§ããªããªããŸãã
3.2ã ã¬ããŒãäœæ
- 詳现ã¬ããŒãã¹ããŒã¿ã¹ã® [ ãã§ã㯠]ãã¿ã³ãã¯ãªãã¯ããŠã詳现ã¬ããŒãã®ååšã¹ããŒã¿ã¹ã確èªããŸãã
- äœæãããŠããªãå Žåã¯ãã¬ããŒããäœæããŸãïŒ[ äœæ ]ãã¿ã³ãã¯ãªãã¯ã§ããå Žåã¯ãã¯ãªãã¯ããŸãïŒã
ãã®çµæãæ°ããã¬ããŒãããŒãã«ãäœæããããã®ååã¯ãDetailStatãã§çµãããŸãã
åã®èª¬æã¯ããã©ããã¬ããŒãã®åã®èª¬æãšåãã§ãããã ãããã®è¡šã«ã¯ããã«è¡ããããŸãïŒã¬ããŒãã®è©³çŽ°ïŒã
ãããã®ããŒãã«DetailStatã¯ãŸããã¯ãªããããŒãã«ã³ããŒããçšãšããŠã¬ããŒããã³ãã¬ãŒãã«æ¿å ¥ãããå ±åæžæ¡ã
3.3ã ã¬ããŒãåæ
詳现ã¬ããŒãïŒè©³çŽ°ã¬ããŒãïŒã®åæã¯ããã©ããã¬ããŒãïŒãã©ããã¬ããŒãïŒã®åæã«äŒŒãŠããŸãããã ããã¯ãšãªããã¹ãã衚瀺ããã³ããŠã³ããŒãããè¿œå ã®æ©äŒããããŸãã
[ 衚瀺 ]ãã¿ã³ãã¯ãªãã¯ãããšã詳现ã¬ããŒãã®å 容ãå«ããŠã£ã³ããŠãéããŸãã
ã
ãŠã£ã³ããŠãReportViewFormãã§ãã¬ã³ãŒãã衚瀺ããŠãœãŒãã§ããŸããã¯ãªãã¯ããããªã¯ãšã¹ãã®ããã¹ãã¯ãããã°ã©ã ãã©ã«ããŒã«ãã¡ã€ã«ãšããŠä¿åãããŸããã¿ãã«ã¯ããªã¯ãšã¹ãããã¹ãããªã¯ãšã¹ãããã¹ãã®æåã®10,000æåã衚瀺ãããŸãã
ã¯ãšãªããã¹ããããŠã³ããŒããããã®æ¹æ³ã¯ã倧ããªãªã¯ãšã¹ããåæã§ããããã«ããããã«äœæãããŸããããããã£ãŠã100ã700 MBã®ãµã€ãºã®ããã¥ã¡ã³ããäœæããæäœãtresã«å«ãŸããŠããå Žåããããã®æäœã®ã¯ãšãªããã¹ãã¯èšå€§ã§ãããããã¯éåžžã«å€§ãããããRAMã§ãããselect * from ... DetailStatãã®èŠæ±ã«ã¯äžååãªå ŽåããããŸããDetailStatã¬ããŒãããŒãã«ã䜿çšããå Žåãã®ãããªç¹å¥ãªãã¥ãŒã¢ãä»ããŠãã¬ã³ãŒãã¯1ã€ã®äžè¬çãªãªã¯ãšã¹ãã§ã¯ãªããåå¥ã®ãªã¯ãšã¹ãã«ãã£ãŠååŸãããŸããããã«ããã倧èŠæš¡ãªã¯ãšãªã®ããã¹ããã¢ããããŒãã§ããŸããã¬ããŒãã«å€§ããªã¯ãšãªããªãå Žåã¯ãSQL Management Studioããäœæ¥ããæ¹ã䟿å©ã§ãã
ã¯ãšãªããã¹ãããã¡ã€ã«ã«é 次ã¢ã³ããŒããããšã倧ããªã¯ãšãªããã¹ãïŒãµã€ãºã500 MB以äžã®ã¢ã³ããŒããããã¯ãšãªããã¹ãïŒãæäœããéã®ã¡ã¢ãªäžè¶³ã®åé¡ã解決ã§ããŸãã
ç£æ¥éçº
説æããMicrosoft SQL Serverãã¬ãŒã¹ã®åéããã³åææ¹æ³ã¯ã2ã€ã®è£œåããã¹ããããšãã«ãã¹ããããŸãããã©ã¡ãã®è£œåãäŒèšã«é¢é£ããŠããŸãã
OLTPã·ã¹ãã ïŒSynerdocsïŒ
å°ããããŒã¿ã®é »ç¹ãªãµã³ããªã³ã°ãåã ã®ã¬ã³ãŒãïŒçä¿¡/çºä¿¡ãããã¥ã¡ã³ãã眲åïŒã®é »ç¹ãªæŽæ°ãå€ãã®ãŠãŒã¶ãŒïŒ1000ã2000人ã®ãã¹ããŠãŒã¶ãŒïŒãã¹ãã¢ãããã·ãŒãžã£ããã³é¢æ°ïŒAPIããŒã¿ããŒã¹ïŒãžã®å€ãã®åŒã³åºããã¹ãã¢ãããã·ãŒãžã£åŒã³åºãã§ã¯ãªãSQLã¯ãšãªåŒã³åºãã¯ã»ãšãã©ãããŸãããè² è·ãã¹ãäžã®ã¯ãšãªã¯æ°åäžä»¶å¢å ããŠããŸããèŠæ±ã¯æ°çŸã®ã°ã«ãŒãã«åéãããŸãã
å®è¡ã®ã³ã¬ã¯ã·ã§ã³ã¯ãè² è·ãã¹ãã®æéïŒæ°æéïŒã«èµ·åãããŸãããã®åŸãæ°åã®ã¬ãã€ãã®ãã¬ãŒã¹ãåæãããã¬ããŒãã«å€æãããŸãã
ãã¹ãã¯å®æçã«å®æœãããŸããããæç¹ã§ãæãããªããã«ããã¯ãèŠã€ããããšãå°é£ã«ãªããŸããã詳现ãªåæã«ã¯èšåšãå¿ èŠã§ãããã¬ããŒããç°¡åã«æ¯èŒã§ããããã«ïŒExcelã®åã«åãŸãããã«ã°ã«ãŒãåããŒã¯çãããå¿ èŠããããŸãïŒããããŠãäžèšã®ã¬ããŒããç»å ŽããŸããã
OLAPã·ã¹ãã ïŒPrestimaïŒ
倧éã®ããŒã¿ã®éžæãšã°ã«ãŒãåãåã ã®ã¬ã³ãŒãã®æŽæ°ïŒäºç®ãã¢ã«ãŠã³ããæçš¿ïŒããã¹ãäžã®ãŠãŒã¶ãŒã¯æ¯èŒçå°ãªãïŒè² è·ã¯ãã¬ããŒãã®çæãéå§ããçããŠãã人ã ã«ãã£ãŠäœæãããŸãïŒãåçã«çæãããã¯ãšãªã®å€ãïŒé·ãã¯ãšãªããã¹ãã2ã€ã®ã¯ãšãªã®éãã¯ãJOINãå«ãã»ã¯ã·ã§ã³ã§ã¯200çªç®ã®æåãWHEREã»ã¯ã·ã§ã³ã§ã¯250çªç®ã®æåã®ã¿ïŒãããŸããŸãªæ¡ä»¶ãæã€å€ãã®ããŒãã«ãžã®åæã¯ãšãªãæéã«å¯Ÿããã¯ãšãªåºæºã®æ確ãªå¹æãæéããã®æé·ãªã¯ãšã¹ãã¯ããªã¯ãšã¹ãã®æ§é ã§ã¯ãªãããã©ã¡ãŒã¿å€ãç°ãªãå ŽåããããŸãã
å®è¡ã®ã³ã¬ã¯ã·ã§ã³ã¯ãæ©èœãã¹ãããã³äœç©ãã¹ãã®æéäžïŒããããæ°æ¥ïŒéå§ãããŸãããã¬ãŒã¹ã¯å®æçã«åæãããã¬ããŒãã«å€æãããŸãã
è€éãªã¯ãšãªã®çµ±èšã1ã€ã®ã°ã«ãŒãã«åé¡ãããªãããã«ããã«ã¯ãã°ã«ãŒãåããŒãæ£ç¢ºã§ãªããã°ãªããŸãããPrepareTextDataããã·ãŒãžã£ã§ã¯ãèšç®ãããããŒã®é·ããæå®ã§ããŸãããŸãããã¬ãŒã¹ã®éãå°ãªãå Žåãé·ãã°ã«ãŒãåããŒã®äœ¿çšã¯éåžžã«æ®éã§ãïŒã¬ããŒãã®é床ã¯é«ããŸãŸã§ãïŒã
èè ãšãªã³ã¯
ãã®èšäºã§çŽ¹ä»ããåæã¬ããŒãã¯ãMikhail IzvekovïŒComputer NPOã®éçºè ïŒãäœæããsqlã¯ãšãªã®åå«ã§ãããªã¯ãšã¹ãã¯ã·ã³ãã«ã§çŸããã§ãïŒ
-- REPLACE X. @Len , -- . , -- , , . -- 26 IContents "select distinct X as Ob", -- , , -- 4000, -- ( , ..). declare @Hours float; declare @CPUSumm int; declare @Len int = 26; select @CPUSumm = SUM(CPU) from Test -- , . select @Hours = CAST(MAX(StartTime) - MIN(StartTime) as float) * 24 from Test -- , . select SUBSTRING(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CAST(TextData as nvarchar(4000)),'0','X'),'1','X'),'2','X'),'3','X'),'4','X'),'5','X'),'6','X'),'7','X'),'8','X'),'9','X'),'XX','X'),'XX','X'),'XX','X'), 1, @Len) as [Query Pattern], sum(CPU) / 1000 as CPU_sec_SUM, avg(CPU) as CPU_msec_AVG, max(CPU) as CPU_msec_MAX, min(CPU) as CPU_msec_MIN, avg(Duration) / 1000 as [AVG_Duration (msec)], avg(Reads) as [Avg Reads], avg(Writes) as [Avg Writes], count(1) as TotalQnt, round(count(1) / @Hours, 2) as Count_per_hour, round(cast(SUM(CPU) as float) / @CPUSumm * 100, 3) as ImpactCPUPerf from Test -- , . where EventClass in (10, 12) and ISNULL(ApplicationName, 'Unknown') in ('SBRSE', 'IS-Builder', 'Unknown') group by SUBSTRING(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CAST(TextData as nvarchar(4000)),'0','X'),'1','X'),'2','X'),'3','X'),'4','X'),'5','X'),'6','X'),'7','X'),'8','X'),'9','X'),'XX','X'),'XX','X'),'XX','X'), 1, @Len)
ãªã¯ãšã¹ããã€ã±ã«ã¯ãå ã®åœ¢åŒã§ã¯äœ¿çšã§ããŸããã§ããã30ã40 GBã®ãã¬ãŒã¹ã®åæã«ã¯æéãããããŸãããŸãããã¬ãŒã¹å ã®ãªã¯ãšã¹ãã®ããã¹ãã¯ãã°ã«ãŒãåããŸã£ããæãŸãªããããªãã®ã§ãããçãããŒïŒ10æåïŒã䜿çšãããšããã¹ãŠã®éžæèŠæ±ãšæŽæ°èŠæ±ãæ··åšããŠããŸããããŸããé·ãããŒïŒ30æå以äžïŒã䜿çšãããšãGUIDãã©ã¡ãŒã¿ãŒã䜿çšããŠã¹ãã¢ãããã·ãŒãžã£ãåŒã³åºããšãåæ§ã®ã°ã«ãŒãåããŒãäœåãäœæãããŸãã
exec [dbo].[getDoc] @id="128500FF-8B90-D060-B490-00CF4FC964FF" --exec [dbo].[getDoc] @id="XFF-X exec [dbo].[getDoc] @id="AABBCCDD-0E0E-1234-B491-0D43C5F6C0F6" --exec [dbo].[getDoc] @id="AABBC
ã°ã«ãŒãåããŒãèšç®ããããã®ããŸããŸãªãªãã·ã§ã³ãè©Šãå§ããŸãããçµæã¯ããããã¡ã€ãªã³ã°ããŒãã«ã®æ°ããåã«èšé²ãããŸããããããŠããã®åã¯ãã§ã«çµæãã°ã«ãŒãåããŠããŸãããããŠãããã¯ãã¹ãŠå§ãŸããŸããã
ããæè¿ã§ã¯ãéææ¥ã«ã圌ãã¯ããŒã·ã£ãšäžç·ã«åº§ã£ãŠå°é£ãªäººçã«ã€ããŠè©±ããŸããããããã²ããæ¿ãããããŠãèšäºãæžãããšã圌ã«äŒããã®ãå¿ããŸããã
ããããããã€ã±ã«ã®ã¹ã¯ãªããã®ã©ã€ã»ã³ã¹ã¯ãŸã ããããŸããããŸããSQLProfilerReportHelperããŒã«ã®ã©ã€ã»ã³ã¹ã¯BSDã§ãããç¡æã§ããè² è·ãã¹ãã«ãã¬ãŒã¹ã¹ã¯ãªãããåã蟌ã¿ããã¬ãŒã¹ãåæããã¬ããŒããçæããŸãã
ãã®ããŒã«ã¯Githubã§å ¥æã§ããŸãïŒhttps : //github.com/polarnik/SQLProfilerReportHelperã
ãã®èšäºã«æ²èŒãããŠããã¬ããŒãã®åçã¯å€ããããããŸãç§å¯ã§ã¯ãããŸãããã¬ããŒãã®å³ãšãäœæäžã®ããŒã«ã®ããŒãã«ã¬ããŒãã®åã®æ§æã«ççŸãããããšã«æ°ä»ããå Žåã¯ãç解ããŠæ±ã£ãŠãã ããã
å®äº
ãã®ã¬ã€ãã§ã¯ãSQL Serverãããã¡ã€ãªã³ã°ããŒã¿ã«åºã¥ããŠã°ã«ãŒãåãããã¬ããŒããã³ã³ãã€ã«ããããã»ã¹ã«ã€ããŠèª¬æããŸããããã¯ããã©ãŒãã³ã¹ãã¹ãäœæ¥ã®10åã®1ã«éããŸãããããããæããéèŠã§ãã
èšäºã®æ¬¡ã®éšåã§ã¯ããã¬ãŒã¹ã«åºã¥ããŠçæãããä»ã®ã¬ããŒãã«ã€ããŠèª¬æããŸãã