I feel motivated when viewers of this blog ask me a follow-up question. Today we are going to see another demonstration which is based on my previous videos. Lots of people have asked me a very interesting question – What will happen if you use three operations COUNT(*), COUNT(1), and SUM(1) in a single statement? Will SQL Server use three scans or a single scan. Well, the answer is pretty straight forward and that is what we are going to see in today’s video of One Scan for 3 Count Sum.
Here are three blog posts you should read and watch the associated video along with it:
- SUM(1) vs COUNT(1) Performance Battle – SQL in Sixty Seconds #177
- COUNT(*) and COUNT(1): Performance Battle – SQL in Sixty Seconds #176
- COUNT(*) and Index – SQL in Sixty Seconds #175
Here is today’s blog post about One Scan for 3 Count Sum. You can also download the script of this video from the blog post here SQL Server – Single Scan for 3 Operations – COUNT(*) COUNT(1) SUM(1)
Well, that’s it for today. If you liked this video, please do not forget to subscribe to my YouTube Channel – SQL in Sixty Seconds.
Here are my few recent videos and I would like to know what is your feedback about them.
- Index Scans – Good or Bad? – SQL in Sixty Seconds #174
- Optimize for Ad Hoc Workloads – SQL in Sixty Seconds #173
- Avoid Join Hints – SQL in Sixty Seconds #172
- One Query Many Plans – SQL in Sixty Seconds #171
Reference:Â Pinal Dave (http://blog.SQLAuthority.com)