Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Checking if more than 0 rows exist.
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.)
![]() |
![]() |