Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

usage of DISTINCT slowing the query

500237Oct 21 2010 — edited Oct 22 2010
Oracle 10g version

Hi,

I am having multiple queries written in this way where eveywhere I have to select the DISTInCT values from tables.
 
SELECT COUNT(DISTINCT(scr.dynamic_handle))
              /* INTO l_cnt */
              FROM staging_scenario_result scr,
                   staging_position sp
             WHERE scr.scenario_name     = :Var1
               AND scr.feed_instance_id  = sp.feed_instance_id
               AND scr.feed_row_id       = sp.feed_row_id
               AND scr.feed_instance_id  = :a_feed_instance_id
               AND sp.summary_flag       = :a_summary_flag
But I am not able to copy paste the explain plan as I am using PL-SQL developer and here posting is image seems no option.
Anyways the issue is everytime I am executing the SP where there are many these kind of queries, its extremely slow.

So please guide me what would be best way to write the query with DISTINCt which can improve performance.
I gone thru many web pages but could not get any better idea to deal with this.

Thanks,
Aashish
This post has been answered by Dom Brooks on Oct 21 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2010
Added on Oct 21 2010
12 comments
4,089 views