June 23, 2011 at 1:00 am
Hi,
Please give me good solution as below SQL statement, application gets error - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Recently upgrade to SQL 2008 from SQL 2000, Error facing after completion upgrade process.
1. view name - Tel_Txt_Li_St_ANOMALY - total 6 records
SELECT SITE, PLANT, A AS EXT, D AS NAME, E AS LOCATION
FROM dbo.TEL_TXT_LI_ST AS st
WHERE (NOT EXISTS
(SELECT Ext
FROM dbo.Tel_Bincard_Detail AS bin
WHERE (Remove_Date IS NULL) AND (Site = st.SITE) AND (Ext = st.A)))
2. view name - Tel_Bincard_Detail_ANOMALY - 20366 records
SELECT Site, 'IT' AS PLANT, Ext, EName AS NAME, Location
FROM dbo.Tel_Bincard_Detail AS bin
WHERE (Remove_Date IS NULL) AND (NOT EXISTS
(SELECT bin.Ext
FROM dbo.TEL_TXT_LI_ST AS st
WHERE (SITE = bin.Site) AND (A = bin.Ext)))
3. Application using final statement - this query taking and gets output 59 seconds. ( here merge with above both views)
SELECT 'Bincard' ANOMALY_IN, count(1) TOTAL FROM
Tel_Txt_Li_St_ANOMALY where site='JMN'
and PLANT='IT'
UNION ALL
SELECT 'List Station' ANOMALY_IN, count(1) TOTAL FROM
Tel_Bincard_Detail_ANOMALY where site='JMN' and PLANT='IT'
Thanks
ananda
June 23, 2011 at 1:12 am
You need to include table and index schema details as well as the execution plan for any query. This will help all the experts to analyze and suggest you some solution.
BTW, make sure you update statistics on your database after migration.
June 23, 2011 at 1:19 am
yes, after migration i have done as below
1. dbcc checkdb with data purity
2. Rebuild index
3. update statistics both all existing statistices and column level
thanks
June 23, 2011 at 1:32 am
ananda.murugesan (6/23/2011)
yes, after migration i have done as below1. dbcc checkdb with data purity
2. Rebuild index
3. update statistics both all existing statistices and column level
thanks
If you rebuild all the indexes, no need to update the statistics then. It will be done automatically.
Where is the schema details and execution plans for your queries. Without them, it is not possible to give a fair judgement.
June 23, 2011 at 4:22 am
execution plan for query
SQL Server Execution Times:
CPU time = 43313 ms, elapsed time = 45799 ms.
June 23, 2011 at 4:31 am
ok.. I think i will ask this 3rd and last time:-)
Without schema and index details, not possible to give best solution. And the numbers that you wrote above are just execution statistics, you need to include execution plan which is in .sqlplan format for others to analyze why the query is performing slow.
June 23, 2011 at 4:35 am
Please post the ACTUAL EXECUTION PLANS of the queries. In addition, please send the output of the following have a better picture of the server.
sp_configure (With show advanced options on)
xp_msver
Also please mention if you have changed and database level or server level options on the server with SQL2K8? I hope the compatibility level of the databases after migration is that of SQL2K8.
June 23, 2011 at 4:37 am
June 23, 2011 at 4:45 am
sorry Mr.
schema name - DBO, and attached file for execution plan file, please find out.
I have changed set ompatible level 100 after upgraded
thanks
June 23, 2011 at 5:03 am
You can see in the plan that it's clearly stating that statistics are missing on columns.
First thing first please do a update stats with full scan on the whole database (I 'wd strongly suggest) and then try rerunning the queries again. Do post the actual execution plan if the problem persists.
June 23, 2011 at 5:11 am
Looking at your views, I suspect blocking as well.
(Bad stats may not help with this.)
Try just using the tables and doing a FULL JOIN.
Something like:
SELECT
CASE WHEN BIN.[Site] IS NULL THEN 'Bincard' ELSE 'List Station' END AS Anomaly_In
,COUNT(1) AS Total
FROM dbo.TEL_TXT_LI_ST ST
FULL JOIN dbo.Tel_Bincard_Detail BIN
ON ST.[Site] = BIN.[Site]
AND ST.A = BIN.Ext
AND BIN.Remove_Date IS NULL
WHERE ST.[Site] IS NULL
OR BIN.[Site] IS NULL
GROUP BY CASE WHEN BIN.[Site] IS NULL THEN 'Bincard' ELSE 'List Station' END
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply