Query performance and tuning

5 pts.
Tags:
GROUP BY statement
ORDER BY statement
Query optimization
Query performance
SQL
SQL development
SQL performance
SQL queries
SQL statements
Hi, I wanted know as to what I can do to my query so that it improves in performance.RIght now it it taking 3-4 hrs because of the large no of records in the DB.If i remove the group by and order by clause for the same no of records it is fast but when it does sorting it hangs.But I need to do the sorting a s i am generating a report out of it.Here is my query, note that a lot more conditions are there in the group by and order by claue. I need a quick solution for this. SELECT A.ACM_AM_ID,B.TCUS_ID,B.CUS_NAME,A.ACM_AC_NUM, A.ACM_ADT_UNIT,C.AAC_USER_ID,F.TFAC_ID,F.FAC_FAC_TYPE, DECODE(F.FAM_SL_NUM, NULL, '', F.FAM_SL_NUM), F.FAM_SGD,DECODE(F.FAM_FAM_TYPE, 'AL', NVL(F.FAM_NEW_LIMIT, 0) * 10, NVL(F.FAM_NEW_LIMIT, 0)) FAM_NEW_LIMIT , FUN_GET_FAC_PURPOSE(F.TFAM_ID, F.FAM_PROD_TYPE), F.FAM_OTH_PURPOSE ,NVL(INTEREST.FPD_SPREAD_RATE, 0, S.TSIM_ID, S.SIM_SRTY_TYPE,S.SIM_SRTY_TYPE_OTH,S.SIM_CAT_ASSET,S.SIM_CAT_ASSET_OTH,S.SIM_SGD,W.WIS_ACM_ID, W.WIS_TYPE ,W.WIS_WISSM_FAM_ID PARENT_ID ,W.TFAM_ID CHILD_ID, W.WIS_SGD, W.WIS_AMT, FAM_LIMIT.AMOUNT ,INTEREST.FPD_INTR_DESC,INTEREST.FPD_VARIANCE FROM T_ACM_DETAIL A,T_FAM F,T_FAM_WIS_SM W, T_CUS_EMP CE,T_CUS_CORCUS_INFO CU,T_CUS_CUSTOMER B,T_SAM_SECURITY S, V_LIMIT_BY_ACM FAM_LIMIT, V_FAM_INTEREST INTEREST WHERE (A.ACM_AM_ID= B.ACM_AM_ID) AND (FAM_LIMIT.ACM_ADT_ID= A.ACM_AM_ID) AND (A.ACM_AM_ID= F.ACM_AM_ID) AND ( CE.TCUS_ID(+) = B.TCUS_ID) AND (CU.TCUS_ID(+) = B.TCUS_ID) AND (B.ACM_AM_ID= F.ACM_AM_ID) AND (W.TFAM_ID (+) = F.TFAM_ID ) AND (INTEREST.TFAM_ID (+) = F.TFAM_ID )AND (S.ACM_AM_IDIS NOT NULL) AND (A.ACM_AM_ID= S.ACM_AM_ID(+)) AND (B.ACM_AM_ID= S.ACM_AM_ID) OR (A.ACM_AM_ID= B.ACM_AM_ID) AND (FAM_LIMIT.ACM_AM_ID= A.ACM_AM_ID) AND (A.ACM_AM_ID= F.ACM_AM_ID) AND (CE.TCUS_ID(+) = B.TCUS_ID) AND (CU.TCUS_ID(+) = B.TCUS_ID) AND (B.ACM_AM_ID= F.ACM_AM_ID) AND (W.TFAM_ID (+) = F.TFAM_ID ) AND (INTEREST.TFAM_ID (+) = F.TFAM_ID ) AND (S.TSIM_ID IS NULL) AND (S.ACM_AM_ID IS NULL) AND (A.ACM_AM_ID= S.ACM_AM_ID(+)) GROUP BY A.ACM_AM_UNIT,A.ACM_AM_ID,B.TCUS_ID ORDER BY A.ACM_AM_UNIT,A.ACM_AM_ID,B.TCUS_ID
ASKED: December 21, 2008  9:34 AM
UPDATED: December 29, 2008  11:30 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

In order to improve the performance of the query you can use NOLOCK for example
SELECT
b.id,
b.name,
( t.id ) AS tag_id,
( t.name ) AS tag_name
FROM
blog_entry b
INNER JOIN
blog_entry_tag_jn btjn (NOLOCK)
ON
b.id = btjn.blog_entry_id
INNER JOIN
tag t (NOLOCK)
ON
btjn.tag_id = t.id

thanx Danish

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following