IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

which is efficient count(*) or count(1) ?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Mon Nov 05, 2007 11:19 am
Reply with quote

Hi ALL,
please can anybody give me the comparison for count(*) and count(1) in terms of efficiency ? please include a detailed view on how to decide in which situation what is better.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Mon Nov 05, 2007 11:32 am
Reply with quote

Hi,


As i seen both returns the same answer , but if you want to improve the efficiency you need to have proper CLUSTER INDEX in the query.




Regard's
Vasanth...... icon_smile.gif
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Mon Nov 05, 2007 11:35 am
Reply with quote

Hi,

Adding to the above answer.

I think of count(*) as counting the number of rows but I have heard people liking count(1) as meaning count where the existence of the row is true (1 meaning true).

I think count(1) gives lesser performance over count(*).


Regard's
Vasanth.......... icon_smile.gif
Back to top
View user's profile Send private message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Mon Nov 05, 2007 11:41 am
Reply with quote

Thanks but can you explain that in more detail.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Mon Nov 05, 2007 12:47 pm
Reply with quote

Hi Ritesh,

pls find the link below, it is explained practically, it would helpfull for you.


justoracle.blogspot.com/2006/12/count-vs-count1.html


Regard's
Vasanth......... icon_smile.gif

"Never Give Up Until U Succeed"
Back to top
View user's profile Send private message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Mon Nov 05, 2007 4:14 pm
Reply with quote

vasanthkumarhb wrote:
Hi Ritesh,

pls find the link below, it is explained practically, it would helpfull for you.


justoracle.blogspot.com/2006/12/count-vs-count1.html


Regard's
Vasanth......... icon_smile.gif

"Never Give Up Until U Succeed"


Yap the link has enough details.
Thanks Vasanth.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Count the number of characters in a f... CA Products 1
Search our Forums:

Back to Top