经过几天的搜索(here和here),我相信我发现了问题,它似乎与this one相同。但是,我已经捕获了两个执行计划来比较它,但是除了执行时间之外它们似乎是相同的。 (数据库服务器是SQL SERVER 2000)
在VB6中执行的查询:
EventClass:SQL:BatchCompleted
EventClass:Audit Logout(我不知道它是否有用)
使用.NET执行的查询(Interop / COM VB6):
EventClass:SQL:BatchCompleted
EventClass:Audit Logout(我不知道它是否有用)
现在,在SQL:BatchStarting和SQL之间使用VB6和.NET(与UltraEdit进行文件比较)的查询捕获执行计划:BatchCompleted EventClass:
Table Scan(OBJECT:([Resgu].[dbo].[stsIns] AS [si]), WHERE:([si].[IdEqIns]=NULL AND [si].[StsstsIns]>=0))
Clustered Index Scan(OBJECT:([Resgu].[dbo].[Uge].[pkUge] AS [u]), WHERE:([u].[StsUge]>=Convert([@1])))
Clustered Index Scan(OBJECT:([Resgu].[dbo].[Btt].[pkBtt] AS [b]), WHERE:([b].[StsBtt]>=Convert([@1])))
Compute Scalar(DEFINE:([Expr1001]=Convert([p].[IdEmp])+' - '+[p].[EmpName]+' - '+[p].[PreEmpName]))
|--Clustered Index Scan(OBJECT:([Resgu].[dbo].[Employee].[pkEmployee] AS [p]), WHERE:([p].[StsEmployee]>=0))
Compute Scalar(DEFINE:([Expr1002]=Convert([t].[IdStruct])+' - '+[t].[LblTurn]+' - '+[s].[LblStruct]))
|--Nested Loops(Inner Join, OUTER REFERENCES:([s].[IdStruct]))
|--Clustered Index Scan(OBJECT:([Resgu].[dbo].[Struct].[pkStruct] AS [s]), WHERE:([s].[StsStruct]>=0))
|--Clustered Index Seek(OBJECT:([Resgu].[dbo].[Turn].[pkTurn] AS [t]), SEEK:([t].[IdStruct]=[s].[IdStruct]), WHERE:([t].[StsTurn]>=0) ORDERED FORWARD)
Compute Scalar(DEFINE:([Expr1002]=Convert([t].[IdStruct])+' - '+[t].[LblTurn]+' - '+[s].[LblStruct]))
|--Nested Loops(Inner Join, OUTER REFERENCES:([s].[IdStruct]))
|--Clustered Index Scan(OBJECT:([Resgu].[dbo].[Struct].[pkStruct] AS [s]), WHERE:([s].[StsStruct]>=0))
|--Clustered Index Seek(OBJECT:([Resgu].[dbo].[Turn].[pkTurn] AS [t]), SEEK:([t].[IdStruct]=[s].[IdStruct]), WHERE:([t].[StsTurn]>=0) ORDERED FORWARD)
Compute Scalar(DEFINE:([Expr1001]=Convert([s].[IdSite])+' - '+[s].[LblSite]))
|--Clustered Index Scan(OBJECT:([Resgu].[dbo].[Site].[pkSite] AS [s]), WHERE:([s].[StsSite]>=0))
Clustered Index Scan(OBJECT:([Resgu].[dbo].[MarketType].[pkMarketType] AS [tm]), WHERE:([tm].[StsMarketType]>=Convert([@1])))
Clustered Index Scan(OBJECT:([Resgu].[dbo].[Flow].[pkFlow] AS [f]), WHERE:([f].[CatFlow]<Convert([@2]) AND [f].[StsFlow]>=Convert([@1])))
Table Scan(OBJECT:([Resgu].[dbo].[TypeInst] AS [ti]), WHERE:([ti].[StsTypeInst]>=Convert([@1])))
Clustered Index Scan(OBJECT:([Resgu].[dbo].[WeaSation].[pkWeaSation] AS [sm]), WHERE:([sm].[StsWeaSation]>=Convert([@1])))
我不是Sql Profiling的专家,所以我想检查一下但是什么?
问候,
弗洛里安
答案 0 :(得分:0)
注意缓存和参数嗅探。我对一些存储过程有一些奇怪的性能问题,并且能够将其缩小到一些糟糕的优化。 http://blogs.msdn.com/b/khen1234/archive/2005/06/02/424228.aspx
答案 1 :(得分:0)
相同的执行计划,但不同的时间。两个连接的connection settings是否相同?服务器负载有什么不同吗?