Which is better - EXISTS check or SELECT COUNT(*) ?

A nice explanation from a detailed article in SQLMag -
Using the T-SQL EXISTS keyword to perform an existence check is almost always faster than using COUNT(*). EXISTS can stop as soon as the logical test proves true, but COUNT(*) must count every row, even after it knows one row has passed the test.

I like collecting tips like these to supplement the numerous tips, tricks & checklists in the (freely downloadable) Patterns & Practices guide "Improving .NET Application Performance and Scalability". I wish they upgraded this .NET bible to include the advances that have happened since the guide was published in 2004.

Comments

Popular posts from this blog

The Mercurial Grok AI Assistant Understands & Speaks Indian Languages

Things Near Me – Find & Learn About Landmarks Nearby