1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

How do I optimize sql query?

Discussion in 'SQL PL/SQL' started by chack66, Jul 16, 2009.

  1. chack66

    chack66 Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    dear members,
    kindly tell me how do i optimize below query.
    Code (SQL):

    SELECT *
      FROM orderentry.physician_notes n
     WHERE (mrno = '00100000072193' OR mrno IN (SELECT other_mrno
                                                  FROM registration.other_mrnos
                                                 WHERE mrno = '00100000072193'))
       AND note_type IN (SELECT note_type_id
                           FROM orderentry.physician_note_type
                          WHERE NVL (show_notes_in_physician_menu, 'N') = 'Y')
       AND signed_date IS NOT NULL;
    Actually i want to see all those patient notes that contaion in REGISTRATION.OTHER_MRNOS table.for this I used " OR" operator. it is good for small data.
    but for huge data query hanged the form.
    kindly reply me as soon as possible.
     
  2. chack66

    chack66 Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    I need this query optimize as soon as possible.
     
  3. salmankhalid

    salmankhalid Forum Advisor

    Messages:
    116
    Likes Received:
    6
    Trophy Points:
    260
    Location:
    Lahore, Pakistan
    its too much difficult to optimize your code as i have no Data base that you are using, but according to the given code there must be other reason that hangs the form....
    what i think the query is perfectly ok and there is no full table scan on any of the given tables......
     
  4. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    Try using Exists cluase.
    This is not a solution , But may work. ..