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: How to obtain HIT COUNT together with query results?

Re: How to obtain HIT COUNT together with query results?

From: Jack Reid <freejak_at_macol.net>
Date: Thu, 22 Apr 1999 23:40:09 -0400
Message-ID: <371FEB97.A4FAF09D@macol.net>


It depends on the environment in which you executing the SELECT.

In SQL*Plus I think you're stuck with two SELECTs. You can speed up the count SELECT by using:

SELECT count(1)
FROM xyz

or

SELECT count(rowid)
FROM xyz

instead of SELECT count(*)

If you're doing this in PL/SQL you'll have the variable %ROWCOUNT available after you empty your cursor to tell you the total number of rows returned.

To get a small sample of rows you can do this:

SELECT col_1, col_2, ...
FROM my_big_table
WHERE this = 'this' AND
that = 'that' AND
rownum < 51

The rule based optimizer allows for small result sets based on a rownum so this should be quite fast. It will quit after retrieving the number of rows you asked for. Received on Thu Apr 22 1999 - 22:40:09 CDT

Original text of this message

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