473,508 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help the performance issue.

Hi,
I have wrote the following sql sentence.Do you have comments to improve
the performance.I have created all the indexed. But it's still very
slow.Thanks
The primary key is proj_ID and Task_UID.

SELECT PR.PROJ_NAME AS PRName, PR.PROJ_ID As PRProjID, PR.TASK_UID As
PRTaskUID, 'Dev' AS GroupType,
Feat.PROJ_ID As FeatProjID, Feat.TASK_UID As FeatTaskUID, Feat.FeatureID AS
FeatureID,
dbo.CreateFIDSort(Feat.FeatureID) as FIDSort, Feat.FeatureName AS
FeatureName, Feat.Entity AS Entity,
Feat.CmtStatus AS CmtStatus, SE.AttrName AS SE, SE.ValueVariant AS SEHRID,
NetworkElement.ValueVariant As NetworkElement,
Pers.FirstName as FirstName, Pers.MiddleInitial as Middle, Pers.LastName as
LastName,
CASE WHEN Priority.ValueVariant Is Null Then 9999 When Priority.ValueVariant
= 0 Then 9999
Else Priority.ValueVariant END AS Priority, 'Doc' AS DocType, Doc.PROJ_ID AS
DocProjID, Doc.TASK_UID AS DocTaskUID,
Doc.ID_Code AS DocNum, Doc.Entity As DocEnt, DocName.Task_Name AS DocName,
DocNotes.Task_RTF_Notes AS DocNotes,
DocDetails.Proj_ID AS DateProjID, DocDetails.Task_UID AS DateTaskUID,
DocDetails.Task_Type
AS DetailTaskType, DocDetDates.TASK_FINISH_DATE AS CWVFinish,
DocDetDates.TASK_BASE_FINISH
AS BasFinish, DocDetDates.TASK_ACT_FINISH AS ActFinish, DocDetDur.TASK_DUR
AS TotalDur, DocDetDur.TASK_REM_DUR AS RemDur,
DocDetDates.TASK_ACT_START AS ActStart, Sortnum.DocNum As DocSortNum,
PR.PROJ_NAME AS PR1Name, 'Disp' As FeatDisp

FROM CPR_enum_ReltoProj Rel WITH (nolock)
INNER JOIN CPR_PATH ReltoFeat with (nolock) ON Rel.PROJ_ID =
ReltoFeat.PRED_PROJ_ID
AND Rel.TASK_UID = ReltoFeat.PRED_Task_UID AND Rel.PROJ_NAME LIKE 'R26.0'
AND ReltoFeat.EDGE_ID = 1
INNER JOIN CPR_TASK_FeatCmtStat Feat WITH (nolock) ON ReltoFeat.SUCC_PROJ_ID
= Feat.PROJ_ID
AND ReltoFeat.SUCC_Task_UID = Feat.TASK_UID AND Feat.CmtStatus <> 'Concept'
AND Feat.CmtStatus <> 'Identified'
AND Feat.CmtStatus Is Not Null
LEFT JOIN ( CPR_PATH FeattoPR WITH (nolock)
INNER JOIN CPR_ENUM_PRtoProj PR WITH (nolock)
ON FeattoPR.PRED_PROJ_ID = PR.PROJ_ID AND FeattoPR.PRED_TASK_UID =
PR.TASK_UID )
ON Feat.PROJ_ID = FeattoPR.SUCC_PROJ_ID AND Feat.TASK_UID =
FeattoPR.SUCC_TASK_UID AND FeattoPR.EDGE_ID = 1
LEFT JOIN CPR_ContainerAttr SE WITH (nolock) ON Feat.PROJ_ID = SE.PROJ_ID
AND Feat.TASK_UID = SE.TASK_UID
AND SE.AttrName in ('SEM','SEA')
LEFT JOIN CPR_Person Pers WITH (nolock) ON Pers.HRID = SE.ValueVariant
LEFT JOIN CPR_ContainerAttr NetworkElement WITH (nolock) ON Feat.PROJ_ID =
NetworkElement.PROJ_ID
AND Feat.TASK_UID = NetworkElement.TASK_UID AND NetworkElement.AttrName =
'NetElem'
LEFT JOIN CPR_ContainerAttr Priority WITH (nolock) ON Feat.PROJ_ID =
Priority.PROJ_ID
AND Feat.TASK_UID = Priority.TASK_UID AND Priority.AttrName = 'FPA'
LEFT JOIN ( CPR_PATH FeattoDoc WITH (nolock)
INNER JOIN CPR_ENUM_AllDocs Doc WITH (nolock)
ON FeattoDoc.SUCC_PROJ_ID = Doc.PROJ_ID AND FeattoDoc.SUCC_TASK_UID =
Doc.TASK_UID AND FeattoDoc.EDGE_ID = 1
AND Doc.ID_Code NOT LIKE '[<]%' AND Doc.Entity in
('FDD','SRD','SRAD','FFRD','VRAD')
LEFT JOIN CPR_DOCSORTNUM Sortnum WITH (nolock) ON Doc.Entity =
Sortnum.DocEnt
INNER JOIN MSP_TASKS DocName WITH (nolock) ON Doc.PROJ_ID = DocName.PROJ_ID
AND Doc.TASK_UID = DocName.TASK_UID
INNER JOIN CPR_ENUM_Task_RTF_Notes DocNotes WITH (nolock) ON Doc.PROJ_ID =
DocNotes.PROJ_ID
AND Doc.TASK_UID = DocNotes.TASK_UID
LEFT JOIN ( CPR_PATH DoctoDet WITH (nolock)
INNER JOIN CPR_ENUM_TASK_Task_Type DocDetails WITH (nolock) ON
(DoctoDet.SUCC_PROJ_ID = DocDetails.PROJ_ID
AND DoctoDet.SUCC_TASK_UID = DocDetails.TASK_UID AND DocDetails.Task_Type
In ('WriteRev', 'RwkRFA', 'PubLive', 'Waived','Review','RFA', 'CustRev'))
LEFT JOIN MSP_TASKS DocDetDates WITH (nolock) ON
(DocDetails.PROJ_ID = DocDetDates.PROJ_ID AND DocDetails.TASK_UID =
DocDetDates.TASK_UID)
LEFT JOIN CPR_ENUM_TASK_Durations DocDetDur WITH (nolock)
ON ( DocDetails.PROJ_ID = DocDetDur.PROJ_ID AND DocDetails.TASK_UID =
DocDetDur.TASK_UID))
ON ( DocName.PROJ_ID = DoctoDet.PRED_PROJ_ID AND DocName.TASK_UID =
DoctoDet.PRED_TASK_UID AND DoctoDet.EDGE_ID = 1))
ON (Feat.PROJ_ID=FeattoDoc.PRED_PROJ_ID AND
Feat.TASK_UID=FeattoDoc.PRED_TASK_UID AND FeattoDoc.EDGE_ID = 1)
WHERE Feat.FeatureID NOT LIKE '[<]%'
ORDER BY PRName, FIDSort, FeatureID, DocSortNum, DocProjID,DocTaskUID,
DateProjID, DateTaskUID
Dec 9 '05 #1
8 2622
You didn't post your DDL. How about using the Index Tuning Wizard?

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Xu, Wei" <xu*@lucent.com> wrote in message
news:dn********@netnews.net.lucent.com...
Hi,
I have wrote the following sql sentence.Do you have comments to improve
the performance.I have created all the indexed. But it's still very
slow.Thanks
The primary key is proj_ID and Task_UID.

SELECT PR.PROJ_NAME AS PRName, PR.PROJ_ID As PRProjID, PR.TASK_UID As
PRTaskUID, 'Dev' AS GroupType,
Feat.PROJ_ID As FeatProjID, Feat.TASK_UID As FeatTaskUID, Feat.FeatureID AS
FeatureID,
dbo.CreateFIDSort(Feat.FeatureID) as FIDSort, Feat.FeatureName AS
FeatureName, Feat.Entity AS Entity,
Feat.CmtStatus AS CmtStatus, SE.AttrName AS SE, SE.ValueVariant AS SEHRID,
NetworkElement.ValueVariant As NetworkElement,
Pers.FirstName as FirstName, Pers.MiddleInitial as Middle, Pers.LastName as
LastName,
CASE WHEN Priority.ValueVariant Is Null Then 9999 When Priority.ValueVariant
= 0 Then 9999
Else Priority.ValueVariant END AS Priority, 'Doc' AS DocType, Doc.PROJ_ID AS
DocProjID, Doc.TASK_UID AS DocTaskUID,
Doc.ID_Code AS DocNum, Doc.Entity As DocEnt, DocName.Task_Name AS DocName,
DocNotes.Task_RTF_Notes AS DocNotes,
DocDetails.Proj_ID AS DateProjID, DocDetails.Task_UID AS DateTaskUID,
DocDetails.Task_Type
AS DetailTaskType, DocDetDates.TASK_FINISH_DATE AS CWVFinish,
DocDetDates.TASK_BASE_FINISH
AS BasFinish, DocDetDates.TASK_ACT_FINISH AS ActFinish, DocDetDur.TASK_DUR
AS TotalDur, DocDetDur.TASK_REM_DUR AS RemDur,
DocDetDates.TASK_ACT_START AS ActStart, Sortnum.DocNum As DocSortNum,
PR.PROJ_NAME AS PR1Name, 'Disp' As FeatDisp

FROM CPR_enum_ReltoProj Rel WITH (nolock)
INNER JOIN CPR_PATH ReltoFeat with (nolock) ON Rel.PROJ_ID =
ReltoFeat.PRED_PROJ_ID
AND Rel.TASK_UID = ReltoFeat.PRED_Task_UID AND Rel.PROJ_NAME LIKE 'R26.0'
AND ReltoFeat.EDGE_ID = 1
INNER JOIN CPR_TASK_FeatCmtStat Feat WITH (nolock) ON ReltoFeat.SUCC_PROJ_ID
= Feat.PROJ_ID
AND ReltoFeat.SUCC_Task_UID = Feat.TASK_UID AND Feat.CmtStatus <> 'Concept'
AND Feat.CmtStatus <> 'Identified'
AND Feat.CmtStatus Is Not Null
LEFT JOIN ( CPR_PATH FeattoPR WITH (nolock)
INNER JOIN CPR_ENUM_PRtoProj PR WITH (nolock)
ON FeattoPR.PRED_PROJ_ID = PR.PROJ_ID AND FeattoPR.PRED_TASK_UID =
PR.TASK_UID )
ON Feat.PROJ_ID = FeattoPR.SUCC_PROJ_ID AND Feat.TASK_UID =
FeattoPR.SUCC_TASK_UID AND FeattoPR.EDGE_ID = 1
LEFT JOIN CPR_ContainerAttr SE WITH (nolock) ON Feat.PROJ_ID = SE.PROJ_ID
AND Feat.TASK_UID = SE.TASK_UID
AND SE.AttrName in ('SEM','SEA')
LEFT JOIN CPR_Person Pers WITH (nolock) ON Pers.HRID = SE.ValueVariant
LEFT JOIN CPR_ContainerAttr NetworkElement WITH (nolock) ON Feat.PROJ_ID =
NetworkElement.PROJ_ID
AND Feat.TASK_UID = NetworkElement.TASK_UID AND NetworkElement.AttrName =
'NetElem'
LEFT JOIN CPR_ContainerAttr Priority WITH (nolock) ON Feat.PROJ_ID =
Priority.PROJ_ID
AND Feat.TASK_UID = Priority.TASK_UID AND Priority.AttrName = 'FPA'
LEFT JOIN ( CPR_PATH FeattoDoc WITH (nolock)
INNER JOIN CPR_ENUM_AllDocs Doc WITH (nolock)
ON FeattoDoc.SUCC_PROJ_ID = Doc.PROJ_ID AND FeattoDoc.SUCC_TASK_UID =
Doc.TASK_UID AND FeattoDoc.EDGE_ID = 1
AND Doc.ID_Code NOT LIKE '[<]%' AND Doc.Entity in
('FDD','SRD','SRAD','FFRD','VRAD')
LEFT JOIN CPR_DOCSORTNUM Sortnum WITH (nolock) ON Doc.Entity =
Sortnum.DocEnt
INNER JOIN MSP_TASKS DocName WITH (nolock) ON Doc.PROJ_ID = DocName.PROJ_ID
AND Doc.TASK_UID = DocName.TASK_UID
INNER JOIN CPR_ENUM_Task_RTF_Notes DocNotes WITH (nolock) ON Doc.PROJ_ID =
DocNotes.PROJ_ID
AND Doc.TASK_UID = DocNotes.TASK_UID
LEFT JOIN ( CPR_PATH DoctoDet WITH (nolock)
INNER JOIN CPR_ENUM_TASK_Task_Type DocDetails WITH (nolock) ON
(DoctoDet.SUCC_PROJ_ID = DocDetails.PROJ_ID
AND DoctoDet.SUCC_TASK_UID = DocDetails.TASK_UID AND DocDetails.Task_Type
In ('WriteRev', 'RwkRFA', 'PubLive', 'Waived','Review','RFA', 'CustRev'))
LEFT JOIN MSP_TASKS DocDetDates WITH (nolock) ON
(DocDetails.PROJ_ID = DocDetDates.PROJ_ID AND DocDetails.TASK_UID =
DocDetDates.TASK_UID)
LEFT JOIN CPR_ENUM_TASK_Durations DocDetDur WITH (nolock)
ON ( DocDetails.PROJ_ID = DocDetDur.PROJ_ID AND DocDetails.TASK_UID =
DocDetDur.TASK_UID))
ON ( DocName.PROJ_ID = DoctoDet.PRED_PROJ_ID AND DocName.TASK_UID =
DoctoDet.PRED_TASK_UID AND DoctoDet.EDGE_ID = 1))
ON (Feat.PROJ_ID=FeattoDoc.PRED_PROJ_ID AND
Feat.TASK_UID=FeattoDoc.PRED_TASK_UID AND FeattoDoc.EDGE_ID = 1)
WHERE Feat.FeatureID NOT LIKE '[<]%'
ORDER BY PRName, FIDSort, FeatureID, DocSortNum, DocProjID,DocTaskUID,
DateProjID, DateTaskUID
Dec 9 '05 #2
Xu, Wei (xu*@lucent.com) writes:
I have wrote the following sql sentence.Do you have comments to
improve the performance.I have created all the indexed. But it's still
very slow.Thanks
I am afraid that is very difficult ot give much input given just the
query text. The fact that there are indexes, does not mean that they
are ussed, because they may not be the right indexes.

Normally, I would ask you to post CREATE TABLE and CREATE INDEX statements
for the query, but this is a very complex query, and I doubt that anyone
would actually analyse it to suggest better indexes or any other tweaks.
And it does not help, having no idea what the meaning of the query is.

There is one thing, though, that I can comment about the query:
dbo.CreateFIDSort(Feat.FeatureID) as FIDSort,


I don't know how many rows your query returns, but if it returns many rows,
the call to the scalar UDF can be costly. You can always try to take it,
to see what the effect it has.

Apart from that, I can only advice you to look at the query plan and running
the query with SET STATISTICS IO ON, to get an idea of exactly what in the
query that is taking time.

It seems to me that the query plan should start with the condition
CPR_PATH.PROJ LIKE 'R26.0' (change to "=" if you can), provided that
that column is indexed. But this is only a guess on my part, that that
column is selective enough.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 9 '05 #3
how many of your tables have more then 100 rows?

which tables have more then a million rows?

Dec 12 '05 #4
Thanks so much. I use the ASP + Sql Server2000, I guess the problem caused
by so many "left join". There are a lot of data in database now. I have
created some indexes. ( I thinks there are not big problems for this
indexes.) I want create some indexes on views but after my test I found it
is same speed as create the indexes on tables. Hope you can give more help.
Thanks again.
Dec 12 '05 #5
xu,wei (xu*@lucent.com) writes:
Thanks so much. I use the ASP + Sql Server2000, I guess the problem
caused by so many "left join". There are a lot of data in database now.
I have created some indexes. ( I thinks there are not big problems for
this indexes.) I want create some indexes on views but after my test I
found it is same speed as create the indexes on tables. Hope you can
give more help.


Unfortunately I can only refer to what I said my previous post. There is a
limit of what can be done over newsgroups. Performance tuning a query given
only the query text is impossible - need to know table and indexes for
that. And for a complex query like this, I would need more than so. Even
with access to the database, it can be a difficult task.

I did mention two things you could check:
1) What happens if you exclude the call to the UDF?
2) Is there an index on CPR_PATH.PROJ?

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 12 '05 #6
again, which are teh big tables????

many left joins doesn't cause performance issues.

Dec 13 '05 #7
Hi There,
Some minor suggestions

try not to use LIKE as in this case
AND Rel.PROJ_NAME LIKE 'R26.0'
Replace it with
AND Rel.PROJ_NAME = 'R26.0'
And Try to replace <> as below
AND Feat.CmtStatus <> 'Concept'
AND Feat.CmtStatus <> 'Identified'
AND Feat.CmtStatus Is Not Null

Let us say other CMTStatus which you want to check are
'Stage1','Stage2' etc
Then You can use
Feat.CmtStatus In ('Stage1','Stage2',.....)
These are the minor suggestions without looking at the database tables
and other aspects like table size , indexes it would be difficult to
arrive at some conclusion

With Warm regards
jatinder Singh

Dec 15 '05 #8
The tables CPR_PATH,CPR_TASK_FeatCmtStat more than 100 rows.

The tables Cpr_containerattr and msp_tasks, cpdr_alldocs more than 1
million row

"Doug" <dr*********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
how many of your tables have more then 100 rows?

which tables have more then a million rows?

Jan 5 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5204
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
10
2495
by: **ham | last post by:
I know that's an old dirty issue; GDI+ almost -the slowest part of the framework - has bothered many developers using it in animations. Even in managed C++ the performance is awful. Now, any dude...
16
1698
by: Ding Lei | last post by:
Dear fellows, I am currently a Java programmer, using it for around 3 years, & felt quite bored with it. IMHO, Java is too strict on lots of things, unlike Perl, There is usually only one or two...
13
2725
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
17
2031
by: 57R4N63R | last post by:
I'm currently building a website for one of the client. There has been few errors here and there, but just recently the problem is getting worse. Basically the symptoms is that when the user try...
4
3252
by: Steph | last post by:
Hi - Trying to chase down a baffling performance issue. Our database has been running very slow lately. So we are performance tuning the database. In doing so, we created a copy of our...
2
2409
by: Brian Tabios | last post by:
Hello Everyone, I have a very complex performance issue with our production database. Here's the scenario. We have a production webserver server and a development web server. Both are running...
2
1554
by: BTabios | last post by:
Hello Everyone, I have a very complex performance issue with our production database. Here's the scenario. We have a production webserver server and a development web server. Both are running...
7
1769
by: rn5a | last post by:
This is the second time I am asking this question in this newsgroup since I haven't got a solution or response from anyone in my previous post & I need to resolve this issue desperately. Sorry for...
5
2014
by: Varangian | last post by:
Hi, I have a performance issue question? which is best (in terms of efficiency and performance, I don't care neatness in code)... building an ArrayList of Object Instances using SqlDataReader...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.