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

Home -> Community -> Usenet -> c.d.o.misc -> Re: count(*) vs count(columnX): Which one is better?

Re: count(*) vs count(columnX): Which one is better?

From: William Boyle <bboyle_at_netway.com>
Date: Sat, 24 Oct 1998 21:04:17 -0700
Message-ID: <3632A341.606B@netway.com>


Robert Chung wrote:
>
> Regarding an SQL statement like this:
> SELECT count(*) FROM tableX where columnX='ABC'
> and
> SELECT count(columnX) FROM tableX where columnX='ABC'
>
> Which one is better for performance? What if columnX has an index?
> Would there be some differences in performance and efficiency? Thank
> you in advance.

These should be equivalent. However, if you changes the syntax as follows, you could get different counts provided columnX allows NULL values.

	select count(*) from tableX;	    -- returns all rows
	select count(columnX) from tableX;  -- returns rows with non-null 
					    -- columnX values.

In your example, though, the results SHOULD be identical.

-Bill Boyle Received on Sat Oct 24 1998 - 23:04:17 CDT

Original text of this message

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