Sunday, July 8, 2007

SQL Alternative Count

Both SQL Query below returns same result but the speed of retrieving data are different.
Copy Below Both Sql Query to Query analyzer to test it. Customers is a Table Name.

1. SELECT rows FROM sysindexes WHERE id = OBJECT_ID('Customers') AND indid <>
You can use sysindexes system table to get number of ROWS. This column contains the total row count for each table in your database. So, you can use the following select statement instead of Below one:

2. SELECT Count(*) FROM Customers
This SQL query performs full table scan to get the row count.

So, you can improve the speed of the SQL query using the Above First SQL instead of Second SQL Query

SQL Alternative Count


Ayisha said...

Nice and knowledgeable gifts for everyone-
Book and Reference

Anonymous said...

WoW nice blog buddy!Actually WoW is my favorite appreciation keyword. I also like to play. Wow Gold. I was looking for info regarding that and saw your website. Its nice and very interesting.

Anonymous said...

The ordinary bat that flies around at night, who is a remarkable nim in the air, cannot take off from a level place aion gold, if it is placed on the floor or flat ground, all it can do is to shuffle about helplessly and aion gold, no doubt, painfully, until it reaches some slight elevation from which it can throw itself into the air. Then, at once, it takes off like a flash aion gold.

The past is gone and static. Nothing we can do will change it.scarlet blade gold, the future is before us and dynamic. Everything we do will affect it rs gold, You laugh at mescarlet blade gold for being different , but I laugh at you for being the same.