Re: Too Many Cursors?

From: Helge Moulding <hmoulding_at_gmail.com>
Date: 4 Oct 2005 12:50:27 -0700
Message-ID: <1128455427.667828.293800_at_g14g2000cwa.googlegroups.com>


bernhard mutschlechner wrote:
> What about using a group function (ORACLE Optimzier does a good job
> usually).
> -- assuming, that val4 makes rows unique whithin a_key
> select b.val2, b.val3
> from b_table b
> where (b.a_key, b.val4) in (
> select b2.a_key, max( b2.val4)
> from b_table b2
> where b2.a_key = in_a_key
> group by b2.a_key)

I've never tried that method before. I've used 0 = (select count of greater rows) and not exists (select greater row). It seems to me that not exists should be a little faster, since it only has to check the table for a single row that beats the current value. The other two methods have to find all rows, whether or not they beat the current value. The difference in timing might be miniscule if the table doesn't have a lot of entries for any given key.

At least that's the way I see that.

I ended up solving my problem by using a temporary table. That gets me the right answer, and does so quickly enough.

--
  Helge Moulding
  hmoulding at gmail dot com                 Just another guy
  http://hmoulding.cjb.net/                  with a weird name
Received on Tue Oct 04 2005 - 21:50:27 CEST

Original text of this message