2013-10-09 28 views
0

查询总结了根据货币分组的前500个账户余额,用于比较来自新SQL 2012服务器和现有服务器的查询以验证新2012服务器中没有更改。DbFit中的大型数据集比较超时

将超时属性设置为| set option | command | 900 |并无济于事。

下面是错误的提取物:

System.Data.SqlClient.SqlException(0x80131904):超时过期。操作完成之前超时的时间或服务器没有响应。 at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader数据流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) 在System.Data.SqlClient.SqlDataReader.SetMetaData(_SqlMetaDataSet元数据,布尔moreInfo) 在System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的数据流,BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System。 Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async) at System.Data.SqlClient.SqlCommand .RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,DbAsyncResult result) at System.Data.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method) at System.Data.SqlClient。 SqlCommand.ExecuteReader(CommandBehavior行为,字符串方法) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.Execute读者(CommandBehavior行为) 在System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集,DataTable [] datatables,Int32 startRecord,Int32 maxRecords,字符串srcTable,IDbCommand命令,CommandBehavior行为) at System.Data.Common.DbDataAdapter。 Fill(DataSet dataSet,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,CommandBehavior行为) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at dbfit.DatabaseTest.GetDataTable(Symbols symbols,String query,IDbEnvironment环境,的Int32 RSNO) 在dbfit.fixture.StoreQuery.DoTable(解析表) 在fitSharp.Fit.Operators.InterpretFlow.DoTable(Tree`1表,解释器activeFixture,布尔流入)

我试图减少从500中检查到300的行数,这似乎工作,但大数据集将是理想的突出任何差异。

我也在考虑更改查询到别的要么打破它以更小的结果集,或创建一个替代

查询低于,如果任何人有一个更好的解决方案,以优化查询:

 select 
     TOP 1000 fab.DateKey,be.BK_ActOId,be.PtId,be.PDesc, 
     be.OId,be.ODesc,be.SubOId,be.SubODesc, 
     rc.Currency,SUM(CASE WHEN rc.Currency = '_NA' THEN FAB.Balance ELSE 0 END) as  bal_OrigCcy 
     ,SUM(CASE WHEN rc.Currency = 'AUD' THEN FAB.Balance ELSE 0 END) as bal_AUD 
     ,SUM(CASE WHEN rc.Currency = 'GBP' THEN FAB.Balance ELSE 0 END) as bal_GBP 
     ,SUM(CASE WHEN rc.Currency = 'SGD' THEN FAB.Balance ELSE 0 END) as bal_SGD 
     ,SUM(CASE WHEN rc.Currency = 'USD' THEN FAB.Balance ELSE 0 END) as bal_USD 
     from olap.v_FactAccB fab 
     inner join OLAP.v_DimCur dc on dc.CurrencyKey = fab.BalanceCurrencyKey 
     inner join olap.v_DimReportingCur rc on rc.CurrencyKey =   fab.ReportingCurrencyKey 
     inner join OLAP.v_DimBusinessEntity be on be.BusinessEntityKey = fab.BusinessEntityKey 
    and rc.Currency in ('_NA', 'AUD', 'GBP', 'SGD','USD') 
    and fab.DateKey = 20130912 
    and fab.PlatformKey = 1 
    group by fab.DateKey, be.BK_ActOId, be.PId, be.PDesc 
    ,be.OId, be.ODesc, be.SubOId, be.SubODesc, rc.Currency 
    order by fab.DateKey, be.BK_ActOId, be.PId, be.PDesc, be.OId, be.ODesc, be.SubOId, be.SubODesc, rc.Curr 

有谁比上述

回答

0

一个其他替代我会重写查询使用PIVOT,而不是重复SUM(CASE...)

例如:

select * from yourtable 
pivot (SUM(balance) for currency in (_NA,AUD,GBP,SGD,USD)) p