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 improve this query?

Re: How to improve this query?

From: Jan Korecki <Jan.Korecki_at_contactor.se>
Date: Mon, 24 Nov 2003 19:49:56 +0100
Message-ID: <3fc2530a$0$97838$57c3e1d3@news3.bahnhof.se>


Tom Miskiewicz wrote:
> Hi!
>
> Thanks for your reply.
>
>

>>If all you want to test for is not null and your column is indexed then

>
> you
>
>>should use
>>select count(*)
>>from table
>>where col is not null;

>
>
> I have been told, that there is no difference between count(*) and count(1).
> Is that right?
>
> Thomas
>
>

correct.

Just be aware that
select count(myfield) from mytable;

will solve your initial question and count all records where myfield is not null. It will do a full table scan even if the column is indexed so you should do what Cris wrote.

Janne! Received on Mon Nov 24 2003 - 12:49:56 CST

Original text of this message

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