Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Checking if more than 0 rows exist.

Re: Checking if more than 0 rows exist.

From: <phil_herring_at_yahoo.com.au>
Date: 10 May 2005 21:04:03 -0700
Message-ID: <1115784243.142062.74950@g44g2000cwa.googlegroups.com>


xhos..._at_gmail.com wrote:

> How about:
> select count(*) from (select * from foo.bar where
> office = 45
> and statement = 199901
> and rownum = 1);

This sounded like a good call, so I tried it.

SQL> select count(*) from
  2 (
  3 select *
  4 from foo.bar
  5 where office = 45
  6 and statement = 199901
  7 and rownum = 1
  8 );

  COUNT(*)


         1

Elapsed: 00:00:08.00

Then I tried it again, sans ROWNUM:

SQL> select count(*) from
  2 (
  3 select *
  4 from foo.bar
  5 where office = 45
  6 and statement = 199901
  7 );

  COUNT(*)


      9275

Elapsed: 00:00:08.07

Conclusion: ROWNUM didn't help.

(Both are indexed lookups, by the way, according to EXPLAIN PLAN.)

Received on Tue May 10 2005 - 23:04:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US