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

Maven Crash Course - Learn Power Query, Power Pivot & DAX in 15 Minutes

"Data Prep & Exploratory Data Analysis" course by Maven Analytics

Oracle Cloud Infrastructure 2024 Generative AI Professional Course & Certification Exam (1Z0-1127-24)