Solved

Please check the SQL

Posted on 2007-11-20
4
215 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now