On 2001-07-07 18:16:26 -0500, Steven Lembark wrote:
> - Steve Howard <[EMAIL PROTECTED]> on 07/07/01 17:54:18 -0500:
> 
> > do a
> > SELECT COUNT(*) FROM <tablename> WHERE ...
> > 
> > A count is almost always faster than actually returning that row, and
> > requires even less network bandwidth to return the result. Of course, it a
> > result of 1 is returned - the row exists.
> 
> Don't try this in Oracle, it immediately degenerates into a 
> table scan.

It shouldn't, and AFAICS it doesnt:

SELECT STATEMENT   
  SORT AGGREGATE  
    INDEX UNIQUE SCAN ITBOSSTEST.TRL_PK

is the result of an explain plan for

    select count(*) from translations where trl_id=100

The unique scan looks good, although I don't understand why oracle wants
to sort a single row :-)

We are using the rule-based optimizer on this database though, since the
cost-based optimizer sometimes acts very strangely (we had a query which
took almost 4 hours with the CBO (two nested full table scans on the
translations table), and less than 0.01 seconds with the RBO).

        hp

-- 
   _  | Peter J. Holzer      | It's nice to fix problems by accident.
|_|_) | Sysadmin WSR / LUGA  |    -- Theo de Raadt
| |   | [EMAIL PROTECTED]        |       <[EMAIL PROTECTED]> 
__/   | http://www.hjp.at/   |       on bugtraq 2001-03-19

PGP signature

Reply via email to