选择不返回任何行 - 跟踪文件中的查询

时间:2016-11-17 17:44:01

标签: sql-server sql-server-2008-r2 ssms sql-server-profiler

使用

imported a trace档案
RowsCount == NULL

虽然analyzing my imported trace file我注意到某些select语句需要花费大量时间(持续时间)和cpu,但最后不会返回任何行(SELECT TextData, ClientProcessID, EventClass , Duration, StartTime, EndTime , Reads, Writes, CPU, RowCounts , EventSequence, TextData_md5_hash , ApplicationName, SPID FROM MyImportedTrace WHERE TextData_md5_hash in (0x4A943F266010BDD2A47179DC3481BC7F) ORDER BY SPID, StartTime, EventSequence )。

TextData

实施例

slow select without any rows

在查询窗口中测试

如果我将同一个查询从Use MyDatabase SELECT ti.EventClass, te.Eventname, Count(*) as CountAsterisk , Sum(ti.RowCounts) as RowCountsSum , Sum(ti.Duration/1000) as DurationSum_ms , Avg(ti.Duration/1000) as DurationAvg_ms FROM TraceImport ti Left JOIN TraceEvents te ON ti.EventClass = te.EventTraceID Group By ti.EventClass, te.Eventname Order By EventClass - 字段复制到查询窗口中,我会收到很多行(> 200000)

问题

  • 查询没有返回任何行的原因可能是什么?
  • 查询是否已终止?
  • 如何识别跟踪文件中的查询执行失败?

接受答案后更新/编辑

此查询

@interface SomeClass : NSObject
@property int anInt;
@end
@implementation SomeClass
@end

typedef void(^CallbackType)(int a);

- (CallbackType)getCallbackToAssignTo:(SomeClass **)indirectPointer {
  return ^(int a){
    NSLog(@"indirectPointer is: %p", indirectPointer);
    NSLog(@"*indirectPointer is: %p", *indirectPointer);
    (*indirectPointer) = [[SomeClass alloc] init];
    (*indirectPointer).anInt = a;
    NSLog(@"After: indirectPointer is: %p", indirectPointer);
    NSLog(@"After: *indirectPointer is: %p", *indirectPointer);
  };
}

- (void)iWillNotDoWhatImSupposedTo {
  SomeClass *directPointer = nil;
  CallbackType cb = [self getCallbackToAssignTo:(&directPointer)];
  NSLog(@"directPointer is pointing to: %p", directPointer);
  NSLog(@"&directPointer is pointing to: %p", &directPointer);
  cb(1);
  NSLog(@"after callback directPointer is: %p", directPointer);
  NSLog(@"after callback &directPointer is: %p", &directPointer);
}

返回此结果

Group Trace Rows by Event Class

1 个答案:

答案 0 :(得分:1)

"extensionProfile": { "extensions": [ (...) { "properties": { "publisher": "Microsoft.Azure.Diagnostics", "type": "IaaSDiagnostics", "typeHandlerVersion": "1.5", "autoUpgradeMinorVersion": true, "settings": { "WadCfg": { "DiagnosticMonitorConfiguration": { "overallQuotaInMB": "50000", "EtwProviders": { "EtwEventSourceProviderConfiguration": [ { "provider": "Microsoft-ServiceFabric-Actors", "scheduledTransferKeywordFilter": "1", "scheduledTransferPeriod": "PT5M", "DefaultEvents": { "eventDestination": "ServiceFabricReliableActorEventTable" } }, { "provider": "Microsoft-ServiceFabric-Services", "scheduledTransferPeriod": "PT5M", "DefaultEvents": { "eventDestination": "ServiceFabricReliableServiceEventTable" } } ], "EtwManifestProviderConfiguration": [ { "provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8", "scheduledTransferLogLevelFilter": "Information", "scheduledTransferKeywordFilter": "4611686018427387904", "scheduledTransferPeriod": "PT5M", "DefaultEvents": { "eventDestination": "ServiceFabricSystemEventTable" } } ] } } }, "StorageAccount": "storageaccountname" } }, "name": "VMDiagnostics_Name" } 返回可能已捕获的每个可能列。

无法保证您正在查看的实际跟踪确实为每个相关事件类捕获sys.fn_trace_gettable

根据您目前提供的信息,没有理由认为跟踪没有像这样设置。

内点击RowCounts,在Tools / SQL Server Profiler窗口中打开应用,点击标签Trace properties并确保列{{} 1}}检查事件类Event selection

SQL Server profiler / Trace properties / Event selection

相关问题