View previous topic :: View next topic
|
Author |
Message |
sree reddy
New User
Joined: 20 Jul 2007 Posts: 27 Location: bangalore
|
|
|
|
I have a SQl to get the Count in the Program
Select count(*) from xxx
where xxx= :xxxxx
Is there any other method of SQL to get the count without using Count(*) in the SQl
Some people says using count(*) with degrade the performace.
thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is there any other method of SQL to get the count without using Count(*) in the SQl |
Sure, but they all take more resources. . .
Quote: |
Some people says using count(*) with degrade the performace. |
Counting rows does not cause degradation. Reading rows does. If the predicate in the example is not an index, the entire table must be read. If this is an index, only those rows needed will be read. |
|
Back to top |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
Count * does not degrade the performance, even I was also think the same but later found out that sometime count * is been used for the existence check of some of the data in the table or not at the moment we should not use the count * but if the requirement want to have the number of rows present then by using count * will not degrade the performance,
However you can use the SQLERRD or get diagnostic for the same feature, check if these functionality does fit in your requirement. |
|
Back to top |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
You can use
SELECT COUNT(YOUR_TABLE_PRIMARY_KEY).
This can ensure that you're using index, which is more efficient. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How does that accomplish the WHERE. . .
Care must be taken to post replies that answer the posted question. . . |
|
Back to top |
|
|
|