Monday, November 3, 2014

SQL: Counting records...

One of the most commonly used tasks in SQL is related to counting records, as the data grows, counting records could become an expensive operation. Folks need to be aware of the environments where counts are being taken, especially while running in production. Performing counts in production could prove to be expensive. In the link given in the blog article below, SQL Server Expert/Writer Aaron Bertrand explores some of the techniques for doing counts and it s advantages/disadvantages:
There are different methods that are discussed:
Using System Views.
Putting table lock on the table whose counts are needed.
Change the isolation method.