由于SQL查询执行时间过长,我在浏览器上遇到了超时错误 [英] I have facing timed out error on browser due to long SQL query execution time

查看:335
本文介绍了由于SQL查询执行时间过长,我在浏览器上遇到了超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询需要很长时间才能执行,因为这个面临的错误在浏览器上超时了



这里是我的查询



我尝试过:



SELECT DISTINCT

View_DistributorRetailerDetailLedger.CompanyName AS SellerName, ISNULL(SumOfContributionAmountBuyerWiseNF.NetworkFamilyAmount,0)

+ ISNULL(SumOfContAmntManuallyWinnerBuyerWiseNetwork.ScehemAmount,0)AS NetworkFamilyAmount,

ISNULL(SumOfContributionAmountBuyerWiseShopkeeper.ShopkeeperAmount,0)+ ISNULL(SumOfContAmntManuallyWinnerByerWiseShopkeeper.ScehemAmount ,0)

AS ShopkeeperAmount,Config_SchemeName_1.Name作为SchemeName

来自SumOfContributionAmountBuyerWiseShopkeeper INNER JOIN

SchemeSetup ON SchemeSetup.AmountTarget * 1000000< = SumOfContributionAmountBuyerWiseShopkeeper 。商业金额INNER JOIN

Config_LedgerDuration ON SumOfContributionAmountBuyerWiseShopkeeper.LedgerDurationID = Config_LedgerDuration.LedgerDurationID AND

SchemeSetup.StartDate = Config_LedgerDuration.StartDate AND SchemeSetup.EndDate = Config_LedgerDuration.EndDate INNER JOIN

Config_SchemeName AS Config_SchemeName_1 ON SchemeSetup.SchemeNameID = Config_SchemeName_1.ID RIGHT OUTER JOIN

发票On SumofContributionAmountBuyerWiseShopkeeper.SellerID = Invoices.SellerID AND

SumOfContributionAmountBuyerWiseShopkeeper.SellerTypeID =发票。 SellerTypeID RIGHT OUTER JOIN

View_DistributorRetailerDetailLedger LEFT OUTER JOIN

SumOfContAmntManuallyWinnerBuyerWiseNetwork RIGHT OUTER JOIN

发票AS Invoices_1 LEFT OUTER JOIN

Config_LedgerDuration AS Config_LedgerDuration_1 INNER JOIN

SchemeSetup AS SchemeSetup_1 INNER JOIN

SumOfContributionAmountBuyerWiseNF ON SchemeSetup_1.AmountTarget * 1000000< = SumOfContributionAmountBuyerWiseNF.BusinessAmount ON

Config_LedgerDuration_1。 StartDate = SchemeSetup_1.StartDate AND Config_LedgerDuration_1.EndDate = SchemeSetup_1.EndDate ON

Invoices_1.SellerID = SumOfContributionAmountBuyerWiseNF.SellerID AND Invoices_1.SellerTypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON

SumOfContAmntManuallyWinnerBuyerWiseNetwork.SellerID = SumOfContributionAmountBuyerWiseNF.SellerID AND

SumOfContAmntManuallyWinnerBuyerWiseNetwork.SellerTypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON

View_DistributorRetailerDeta ilLedger.ID = SumOfContributionAmountBuyerWiseNF.SellerID AND

View_DistributorRetailerDetailLedger.TypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON

SumOfContributionAmountBuyerWiseShopkeeper.SellerID = View_DistributorRetailerDetailLedger.ID AND

SumOfContributionAmountBuyerWiseShopkeeper。 SellerTypeID = View_DistributorRetailerDetailLedger.TypeID LEFT OUTER JOIN

SumOfContAmntManuallyWinnerByerWiseShopkeeper ON

SumOfContributionAmountBuyerWiseShopkeeper.SellerID = SumOfContAmntManuallyWinnerByerWiseShopkeeper.SellerID AND

SumOfContributionAmountBuyerWiseShopkeeper.SellerTypeID = SumOfContAmntManuallyWinnerByerWiseShopkeeper.SellerTypeID

WHERE(SchemeSetup.SchemeNameID = @ SchemeID)AND(View_DistributorRetailerDetailLedger.ID<> 138)

解决方案

和?您对我们的期望是什么? :笑:



从SQL开始并描述查询:如何:使用SQL事件探查器 [ ^ ]

这将为您提供一堆信息,以便查看并查找查询速度慢的地方 - 然后您可以重新组织数据或重新处理查询以改进速度。



我们不能这样做:我们无法访问您的数据,因此如果我们想要的话,我们甚至无法运行查询!

my query is taking long time to execute due to this facing error timed out on browser

here is my query

What I have tried:

SELECT DISTINCT
View_DistributorRetailerDetailLedger.CompanyName AS SellerName, ISNULL(SumOfContributionAmountBuyerWiseNF.NetworkFamilyAmount, 0)
+ ISNULL(SumOfContAmntManuallyWinnerBuyerWiseNetwork.ScehemAmount, 0) AS NetworkFamilyAmount,
ISNULL(SumOfContributionAmountBuyerWiseShopkeeper.ShopkeeperAmount, 0) + ISNULL(SumOfContAmntManuallyWinnerByerWiseShopkeeper.ScehemAmount, 0)
AS ShopkeeperAmount, Config_SchemeName_1.Name as SchemeName
FROM SumOfContributionAmountBuyerWiseShopkeeper INNER JOIN
SchemeSetup ON SchemeSetup.AmountTarget * 1000000 <= SumOfContributionAmountBuyerWiseShopkeeper.BusinessAmount INNER JOIN
Config_LedgerDuration ON SumOfContributionAmountBuyerWiseShopkeeper.LedgerDurationID = Config_LedgerDuration.LedgerDurationID AND
SchemeSetup.StartDate = Config_LedgerDuration.StartDate AND SchemeSetup.EndDate = Config_LedgerDuration.EndDate INNER JOIN
Config_SchemeName AS Config_SchemeName_1 ON SchemeSetup.SchemeNameID = Config_SchemeName_1.ID RIGHT OUTER JOIN
Invoices ON SumOfContributionAmountBuyerWiseShopkeeper.SellerID = Invoices.SellerID AND
SumOfContributionAmountBuyerWiseShopkeeper.SellerTypeID = Invoices.SellerTypeID RIGHT OUTER JOIN
View_DistributorRetailerDetailLedger LEFT OUTER JOIN
SumOfContAmntManuallyWinnerBuyerWiseNetwork RIGHT OUTER JOIN
Invoices AS Invoices_1 LEFT OUTER JOIN
Config_LedgerDuration AS Config_LedgerDuration_1 INNER JOIN
SchemeSetup AS SchemeSetup_1 INNER JOIN
SumOfContributionAmountBuyerWiseNF ON SchemeSetup_1.AmountTarget * 1000000 <= SumOfContributionAmountBuyerWiseNF.BusinessAmount ON
Config_LedgerDuration_1.StartDate = SchemeSetup_1.StartDate AND Config_LedgerDuration_1.EndDate = SchemeSetup_1.EndDate ON
Invoices_1.SellerID = SumOfContributionAmountBuyerWiseNF.SellerID AND Invoices_1.SellerTypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON
SumOfContAmntManuallyWinnerBuyerWiseNetwork.SellerID = SumOfContributionAmountBuyerWiseNF.SellerID AND
SumOfContAmntManuallyWinnerBuyerWiseNetwork.SellerTypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON
View_DistributorRetailerDetailLedger.ID = SumOfContributionAmountBuyerWiseNF.SellerID AND
View_DistributorRetailerDetailLedger.TypeID = SumOfContributionAmountBuyerWiseNF.SellerTypeID ON
SumOfContributionAmountBuyerWiseShopkeeper.SellerID = View_DistributorRetailerDetailLedger.ID AND
SumOfContributionAmountBuyerWiseShopkeeper.SellerTypeID = View_DistributorRetailerDetailLedger.TypeID LEFT OUTER JOIN
SumOfContAmntManuallyWinnerByerWiseShopkeeper ON
SumOfContributionAmountBuyerWiseShopkeeper.SellerID = SumOfContAmntManuallyWinnerByerWiseShopkeeper.SellerID AND
SumOfContributionAmountBuyerWiseShopkeeper.SellerTypeID = SumOfContAmntManuallyWinnerByerWiseShopkeeper.SellerTypeID
WHERE (SchemeSetup.SchemeNameID =@SchemeID) AND (View_DistributorRetailerDetailLedger.ID <> 138)

解决方案

And? What do you expect us to do about it? :laugh:

Start with SQL and profile the query: How To: Use SQL Profiler[^]
This will give you a heap of information to look though and work out where your query is slow - you can then work on either reorganising your data or reworking the query to improve the speed.

We can't do that: we don't have any access to your data, so we couldn't even run the query if we wanted to!


这篇关于由于SQL查询执行时间过长,我在浏览器上遇到了超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆