Solved

Please check the SQL

Posted on 2007-11-20
4
217 Views
Last Modified: 2010-03-20
Can I simplify the query(faster)?

SELECT   Distinct CATGRPDESC.CATGROUP_ID,
         CATGRPDESC.NAME
FROM     CATGRPATTR,
         CATGRPREL,
         CATGRPDESC,
         CATGRPREL CATGRPREL2,
         IMCAPPLICATIONS,
         IMCCATLNREL rel
WHERE    CATGRPATTR.CATGROUP_ID=CATGRPREL.CATGROUP_ID_PARENT
AND      CATGRPDESC.CATGROUP_ID=CATGRPREL.CATGROUP_ID_PARENT
AND      CATGRPREL.CATGROUP_ID_CHILD IN ()
AND      CATGRPATTR.DESCRIPTION IN ()
AND      CATGRPREL2.CATGROUP_ID_PARENT = CATGRPREL.CATGROUP_ID_CHILD
AND      CATGRPREL2.CATGROUP_ID_CHILD = IMCAPPLICATIONS.LINE_ID
AND      IMCAPPLICATIONS.VID IN ()
AND      rel.Line_ID = IMCAPPLICATIONS.LINE_ID
AND      rel.LINE_ID IN ()
AND      rel.Catalog_ID = CATGRPDESC.CATGROUP_ID
ORDER BY IMCCRP.CATGRPDESC.NAME FOR FETCH ONLY

Thanks
Krishna
0
Comment
Question by:vvsrk76
4 Comments
 
LVL 19

Accepted Solution

by:
NickUpson earned 125 total points
ID: 20321195
mostly likely you need to add one or more indexes onto the tables, start with the fields used to join between tables
0
 
LVL 25

Assisted Solution

by:imitchie
imitchie earned 125 total points
ID: 20322517
that is as simplified as the query gets. you can't achieve performance gains by modifying the select further. as Nick has said, the key is to have an index for all the join conditions

i.e.
CATGRPATTR.CATGROUP_ID,
CATGRPREL.CATGROUP_ID_PARENT,
CATGRPDESC.CATGROUP_ID,
CATGRPREL.CATGROUP_ID_PARENT,
CATGRPREL.CATGROUP_ID_CHILD
etc
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20953234
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question