2013-10-09 64 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