DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Help Need - SQL Tuning in Joining Views

  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    22

    Question Help Need - SQL Tuning in Joining Views

    Hi Everybody,

    Here I have a query based on 2 views.
    First View - PREFERRED_MAILING_ADDRESS, is combination of PARTY Details, Relationships, Person Contact, Person Sites and Locations.
    Second View - MSP_PARTY_RELATIONSHIP_V, Combination of Party Details and Relationships.

    Here is the Query:

    SELECT MSP_PARTY_RELATIONSHIP_V.END_DATE, MSP_PARTY_RELATIONSHIP_V.OBJECT_PARTY_NAME, MSP_PARTY_RELATIONSHIP_V.PARTY_ID,
    MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP, MSP_PARTY_RELATIONSHIP_V.STATUS, XXX_PREFERRED_MAILING_ADDRESS.ADDRESS1,
    XXX_PREFERRED_MAILING_ADDRESS.IDENTIFYING_ADDRESS_FLAG,
    XXX_PREFERRED_MAILING_ADDRESS.ORIG_SYSTEM_REFERENCE

    FROM APPS.MSP_PARTY_RELATIONSHIP_V MSP_PARTY_RELATIONSHIP_V, APPS.XXX_PREFERRED_MAILING_ADDRESS XXX_PREFERRED_MAILING_ADDRESS

    WHERE ( ( MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID = XXX_PREFERRED_MAILING_ADDRESS.PER_PARTY_ID ) AND
    MSP_PARTY_RELATIONSHIP_V.STATUS = XXX_PREFERRED_MAILING_ADDRESS.REL_STATUS ) AND
    UPPER(MSP_PARTY_RELATIONSHIP_V.STATUS) = UPPER('A') AND
    --UPPER(XXX_PREFERRED_MAILING_ADDRESS.REL_STATUS) = UPPER('A') AND
    ( UPPER(MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP) = UPPER('Society Member Of') AND
    UPPER(MSP_PARTY_RELATIONSHIP_V.OBJECT_PARTY_NAME) LIKE UPPER('Tax%') AND 1 = 1 )

    It is taking lot of Time and never get back the result but when I re-write the query (Condition) like below,

    --UPPER(MSP_PARTY_RELATIONSHIP_V.STATUS) = UPPER('A') AND
    UPPER(XXX_PREFERRED_MAILING_ADDRESS.REL_STATUS) = UPPER('A') AND

    It came up within Seconds.I just added PREFERRED_MAILING_ADDRESS view in the condition list.The situation here is I need the query in the Previous style..Please let me know if you need any more information..Thanks in Advance..
    previous


    Here is the Code for Newly created View:

    CREATE OR REPLACE VIEW XXX_PREFERRED_MAILING_ADDRESS as (
    SELECT MSP_PERSON_LOCATIONS_V.ADDRESS1,
    MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15,
    MSP_PERSON_LOCATIONS_V.CITY,
    MSP_PERSON_LOCATIONS_V.COUNTY,
    MSP_PERSON_SITES_V.IDENTIFYING_ADDRESS_FLAG,
    MSP_PERSON_DETAILS_V.ORIG_SYSTEM_REFERENCE,
    MSP_PERSON_DETAILS_V.table_name,

    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10,
    MSP_PERSON_DETAILS_V.party_ATTRIBUTE3,
    MSP_PERSON_DETAILS_V.PERSON_FIRST_NAME ,
    MSP_PERSON_DETAILS_V.PERSON_LAST_NAME,
    MSP_PERSON_DETAILS_V.PARTY_ID PER_PARTY_ID,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE5 PERSON_STATUS,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE7 PERSON_TYPE,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE8 PENDING_ORG_INFO,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE14 PRINT_FLAG,
    MSP_PERSON_DETAILS_V.STATUS,
    MSP_PERSON_DETAILS_V.PERSON_PRE_NAME_ADJUNCT TITLE,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE11 WEBUSER_ID,
    MSP_PERSON_DETAILS_V.email_address,

    --FOLLOWING TWO LINES ADDED BY KRISHNA ON 02-APR-04 TO GET THE MIDDLE NAME,MAILSTOP
    MSP_PERSON_DETAILS_V.PERSON_MIDDLE_NAME,
    MSP_PERSON_DETAILS_V.MAILSTOP,



    MSP_PERSON_DETAILS_V.LEGACY_MEMBER_NUMBER,

    MSP_PERSON_DETAILS_V.PARTY_NUMBER,





    MSP_PERSON_LOCATIONS_V.POSTAL_CODE,
    MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP,
    MSP_PERSON_LOCATIONS_V.STATE,
    MSP_PARTY_RELATIONSHIP_V.STATUS REL_STATUS,
    MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE1 Business_category,
    MSP_PARTY_RELATIONSHIP_V.attribute2 Position,


    MSP_PERSON_SITES_V.PARTY_ID SITES_PARTY_ID,
    MSP_PARTY_RELATIONSHIP_V.PARTY_ID REL_PARTY_ID,
    MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID REL_SUBJECT_ID,
    MSP_PARTY_RELATIONSHIP_V.OBJECT_ID REL_OBJECT_ID,
    decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',MSP_PARTY_RELATIONSHIP_V.OBJECT_PARTY_NAME,null) Per_related_organization

    FROM APPS.MSP_PERSON_SITES_V MSP_PERSON_SITES_V,
    APPS.MSP_PERSON_LOCATIONS_V MSP_PERSON_LOCATIONS_V,
    APPS.MSP_PARTY_RELATIONSHIP_V MSP_PARTY_RELATIONSHIP_V,
    APPS.MSP_PERSON_DETAILS_V MSP_PERSON_DETAILS_V
    WHERE ( ( MSP_PERSON_SITES_V.LOCATION_ID = MSP_PERSON_LOCATIONS_V.LOCATION_ID AND
    MSP_PERSON_SITES_V.PARTY_ID = MSP_PERSON_LOCATIONS_V.PARTY_ID ) AND
    ( MSP_PERSON_DETAILS_V.PARTY_ID = MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID ) AND

    MSP_PERSON_DETAILS_V.PARTY_ID = MSP_PERSON_SITES_V.PARTY_ID )

    AND ( decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15,1))=( decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship','Y',1))
    AND ( MSP_PARTY_RELATIONSHIP_V.STATUS = 'A' )
    AND ( MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP = 'Employee Of' ) AND
    ( MSP_PERSON_SITES_V.IDENTIFYING_ADDRESS_FLAG = 'Y' )

    AND NOT EXISTS
    (
    SELECT 'X'
    FROM APPS.MSP_PERSON_SITES_V SUB_MSP_PERSON_SITES_V,
    APPS.MSP_PARTY_RELATIONSHIP_V SUB_MSP_PARTY_RELATIONSHIP_V,
    APPS.MSP_PERSON_DETAILS_V SUB_MSP_PERSON_DETAILS_V
    WHERE ( ( SUB_MSP_PERSON_DETAILS_V.PARTY_ID = SUB_MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID ) AND
    ( decode(SUB_MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',SUB_MSP_PARTY_RELATIONSHIP_V.object_ID, SUB_MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID) = SUB_MSP_PERSON_SITES_V.PARTY_ID ) )
    AND ( decode(SUB_MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',SUB_MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15,1))=( decode(SUB_MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship','Y',1))
    AND ( SUB_MSP_PARTY_RELATIONSHIP_V.STATUS = 'A' )
    AND ( SUB_MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP = 'Employee Of' ) AND
    ( SUB_MSP_PERSON_SITES_V.IDENTIFYING_ADDRESS_FLAG = 'Y' )
    AND SUB_MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID = MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID
    -- AND SUB_MSP_PERSON_DETAILS_V.ORIG_SYSTEM_REFERENCE = MSP_PERSON_DETAILS_V.ORIG_SYSTEM_REFERENCE
    AND SUB_MSP_PERSON_DETAILS_V.PARTY_ID = MSP_PERSON_DETAILS_V.PARTY_ID )

    union all


    SELECT MSP_PERSON_LOCATIONS_V.ADDRESS1,
    MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15,
    MSP_PERSON_LOCATIONS_V.CITY,
    MSP_PERSON_LOCATIONS_V.COUNTY,
    MSP_PERSON_SITES_V.IDENTIFYING_ADDRESS_FLAG,
    MSP_PERSON_DETAILS_V.ORIG_SYSTEM_REFERENCE,
    MSP_PERSON_DETAILS_V.table_name,

    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10,
    -- ADDED BY KRISHNA ON 19-MAY-04 TO GET THE MEMEBER JOIN DATE IN preferred mailing address folder
    MSP_PERSON_DETAILS_V.party_ATTRIBUTE3,
    MSP_PERSON_DETAILS_V.PERSON_FIRST_NAME ,
    MSP_PERSON_DETAILS_V.PERSON_LAST_NAME,
    MSP_PERSON_DETAILS_V.PARTY_ID PER_PARTY_ID,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE5 PERSON_STATUS,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE7 PERSON_TYPE,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE8 PENDING_ORG_INFO,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE14 PRINT_FLAG,
    MSP_PERSON_DETAILS_V.STATUS,
    MSP_PERSON_DETAILS_V.PERSON_PRE_NAME_ADJUNCT TITLE,
    MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE11 WEBUSER_ID,
    MSP_PERSON_DETAILS_V.email_address,

    --FOLLOWING TWO LINES ADDED BY KRISHNA ON 02-APR-04 TO GET THE MIDDLE NAME,MAILSTOP
    MSP_PERSON_DETAILS_V.PERSON_MIDDLE_NAME,
    MSP_PERSON_DETAILS_V.MAILSTOP,



    MSP_PERSON_DETAILS_V.LEGACY_MEMBER_NUMBER,

    MSP_PERSON_DETAILS_V.PARTY_NUMBER,


    MSP_PERSON_LOCATIONS_V.POSTAL_CODE,
    MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP,
    MSP_PERSON_LOCATIONS_V.STATE,
    MSP_PARTY_RELATIONSHIP_V.STATUS REL_STATUS,
    MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE1 Business_category,
    MSP_PARTY_RELATIONSHIP_V.attribute2 Position,


    MSP_PERSON_SITES_V.PARTY_ID SITES_PARTY_ID,
    MSP_PARTY_RELATIONSHIP_V.PARTY_ID REL_PARTY_ID,
    MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID REL_SUBJECT_ID,
    MSP_PARTY_RELATIONSHIP_V.OBJECT_ID REL_OBJECT_ID,
    decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',MSP_PARTY_RELATIONSHIP_V.OBJECT_PARTY_NAME,null) Per_related_organization

    --MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    FROM APPS.MSP_PERSON_SITES_V MSP_PERSON_SITES_V,
    APPS.MSP_PERSON_LOCATIONS_V MSP_PERSON_LOCATIONS_V,
    APPS.MSP_PARTY_RELATIONSHIP_V MSP_PARTY_RELATIONSHIP_V,
    APPS.MSP_PERSON_DETAILS_V MSP_PERSON_DETAILS_V
    WHERE ( ( MSP_PERSON_SITES_V.LOCATION_ID = MSP_PERSON_LOCATIONS_V.LOCATION_ID AND
    MSP_PERSON_SITES_V.PARTY_ID = MSP_PERSON_LOCATIONS_V.PARTY_ID ) AND
    ( MSP_PERSON_DETAILS_V.PARTY_ID = MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID ) AND

    ( decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',MSP_PARTY_RELATIONSHIP_V.object_ID, MSP_PARTY_RELATIONSHIP_V.SUBJECT_ID) = MSP_PERSON_SITES_V.PARTY_ID ) )

    --FOLLOWING LINES ADDED BY Krishna on 07-Apr-04 to fix the section memebrs count commented following line
    AND ( decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship',MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15,1))=( decode(MSP_PERSON_DETAILS_V.PARTY_ATTRIBUTE10
    ,'Business Relationship','Y',1))
    --AND ( MSP_PARTY_RELATIONSHIP_V.ATTRIBUTE15 = 'Y' )

    AND ( MSP_PARTY_RELATIONSHIP_V.STATUS = 'A' )
    AND ( MSP_PARTY_RELATIONSHIP_V.RELATIONSHIP = 'Employee Of' ) AND
    ( MSP_PERSON_SITES_V.IDENTIFYING_ADDRESS_FLAG = 'Y' )
    )
    BVRAM

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    If each individual view runswell, then you could try ...
    Code:
    SELECT 
    MSP_PARTY_RELATIONSHIP_V.END_DATE, 
    MSP_PARTY_RELATIONSHIP_V.OBJECT_PARTY_NAME,
    ...
    FROM (SELECT * FROM APPS.MSP_PARTY_RELATIONSHIP_V WHERE ROWNUM >= 1) MSP_PARTY_RELATIONSHIP_V,
    (SELECT * FROM APPS.XXX_PREFERRED_MAILING_ADDRESS WHERE ROWNUM >=1 )XXX_PREFERRED_MAILING_ADDRESS
    
    WHERE ...
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Mar 2004
    Location
    California
    Posts
    22

    Not Returning Data

    Hi,

    Thanks for your Help but with your idea, it doesn't return any data back. ACtually I want to know why its happenning and what is the solution.

    Here is the Query Again:

    SELECT MSP_PARTY_RELATIONSHIP_V.END_DATE,
    ........
    FROM APPS.MSP_PARTY_RELATIONSHIP_V MSP_PARTY_RELATIONSHIP_V, APPS.XXX_PREFERRED_MAILING_ADDRESS XXX_PREFERRED_MAILING_ADDRESS
    WHERE .....
    UPPER(MSP_PARTY_RELATIONSHIP_V.STATUS) = UPPER('A') AND
    --UPPER(XXX_PREFERRED_MAILING_ADDRESS.REL_STATUS) = UPPER('A')
    .....
    ...
    Above one not getting back but below one getting back data in SECs.

    SELECT MSP_PARTY_RELATIONSHIP_V.END_DATE,
    ........
    FROM APPS.MSP_PARTY_RELATIONSHIP_V MSP_PARTY_RELATIONSHIP_V, APPS.XXX_PREFERRED_MAILING_ADDRESS XXX_PREFERRED_MAILING_ADDRESS
    WHERE .....
    --UPPER(MSP_PARTY_RELATIONSHIP_V.STATUS) = UPPER('A') AND
    UPPER(XXX_PREFERRED_MAILING_ADDRESS.REL_STATUS) = UPPER('A')
    .....


    Thanks for your HELP..
    BVRAM

  4. #4
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    the obivious reason would be the plan has changed..

    can u post the plan ? (but please make it structured i mean put in codes)
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  5. #5
    Join Date
    Mar 2004
    Location
    California
    Posts
    22

    Angry Plan Changed

    I am really surprising, Why the query returning data back..Its hanging there only..Please see the attachments for Plan Mehtods for Working and Non-Working Queries..I got this Plan Method from PL/SQL Developer..

    Please let me know if you need any more information.

    Thanks
    Attached Files Attached Files
    BVRAM

  6. #6
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    I have seen the plan.. and as i said the plan will obiviously be different.. Its seems me like the qry which is taking time is using all wrong indexes..

    You may like to look the codes of views and the availiable indexes and may try out hints ..


    Abhay.
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  7. #7
    Join Date
    Mar 2004
    Location
    California
    Posts
    22

    Angry Index Hints

    Hi Nice,

    Thanks for your Time. Actually I have the master views of Person_Details_V, Relationship_V, and Person_sites_V. based on this I need to create XXX_PREFERRED_MAILING_ADDRESS after that I need to join the view (XXX) with other views like Person_Details_V, Relationship_V and Person_Sites_V....What do you suggest Giving HINTS to view XXX or Individual Views ?
    Please suggest me what kind of material, I may need to go through for achieve this TASK.

    I appreciate your help..


    Regards
    BVRAM

  8. #8
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Too many complicated views spoil the execution plan.

    Simply go for PL/SQL procedure.
    Use one cursor for one table and pass parameters to filter rows.
    You will be better off in the long run.

    Tamil

  9. #9
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Originally posted by tamilselvan
    Too many complicated views spoil the execution plan.

    Simply go for PL/SQL procedure.
    Use one cursor for one table and pass parameters to filter rows.
    You will be better off in the long run.

    Tamil
    Not convinced of that. If the original SQL can be tuned it'd always be faster than a cursor-based solution.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  10. #10
    Join Date
    Mar 2004
    Location
    California
    Posts
    22

    Angry Tuning Joins

    Hi Guys,

    Acutally we can't go for PL/SQL Procedure at this time, we need to only by tuning the query

    Regards
    BVRAM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width