A Shot of SQLEspresso

SQL Blogs by Monica Morehouse (Rathbun)

  • Home
  • Session Downloads
  • Event Calendar
  • PASS
    • Hampton Roads SQL User Group
    • SQL Saturday
    • PASS WIT VC
  • DCAC
  • Contact Me
    • Disclaimer
  • Home
  • Session Downloads
  • Event Calendar
  • PASS
    • Hampton Roads SQL User Group
    • SQL Saturday
    • PASS WIT VC
  • DCAC
  • Contact Me
    • Disclaimer

No Widgets found in the Sidebar Alt!

  • New SQL Version

    Approximate COUNT DISTINCT

    January 3, 2019 /

    We all have written queries that use COUNT DISTINCT to get the unique number of non-NULL values from a table. This process can generate a noticeable performance hit especially for larger tables with millions of rows. Many times, there is no way around this. To help mitigate this overhead SQL Server 2019 introduces us to approximating the distinct count with the new APPROX_COUNT_DISTINCT function. The function approximates the count within a 2% precision to the actual answer at a fraction of the time. Let’s see this in action. In this example, I am using the AdventureworksDW2016CTP3 sample database which you can download here.  SET STATISTICS IO ON SELECT COUNT(DISTINCT([SalesOrderNumber])) as DISTINCTCOUNT…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    It’s time to speak again!

    December 1, 2015

    Static Data Masking (SSMS 18.0 Preview)

    December 19, 2018

    Why DBAs Still Need to Know the Foundations of SQL Server

    August 19, 2025
  • Indexes,  New SQL Version

    New Resumable Online Index Create SQL Server 2019

    November 28, 2018 /

    SQL Server 2019 brings a very exciting new feature that, is long overdue. Resumable online index create is one of my favorite new things. This paired with the Resumable Index Rebuilds introduced with SQL Server 2017 really gives database administrators much more control over index processes. Have you ever started to build a new index on very large table only to have users call and complain their process is hung, not completing, or system is slow? That’s when you realize you’re the cause because you tried to sneak in a new index. I have many times, because creating a new index can impact performance and can be a problematic process…

    Read More
    Monica Morehouse (Rathbun)

    Related Posts

    The Mystery of SQL Server 2025’s New Tricks – Scooby Dooing Episode 5

    September 17, 2025

    What is Automatic Tuning in Azure SQL Database

    August 28, 2018

    Bloggers Should Have Reach

    February 14, 2018

About Me

Monica Morehouse (Rathbun)

Microsoft MVP, Performancing Tuning Expert, Leader Hampton Roads SQL Server User Group, Read More…

Consulting

Sessions List

Favorite Tidbits

  • Reminder to Developers

Topic Categories

  • Azure
  • Back to Basics
  • Configurations
  • Data Masking
  • DevOps
  • Encryption
  • Idera Ace
  • Important Links
  • Indexes
  • Lone DBA
  • Misc
  • MVP
  • New SQL Version
  • Performance Tuning
  • Posts with Scripts
  • Problems & Solutions
  • Quick and Dirty
  • Security
  • Speaking
  • SQL Family
  • SQLSaturday
  • SSRS
  • Summit
  • Training
  • TSQL Tuesday
  • Uncategorized

Top Posts & Pages

  • Understanding Columnstore Indexes in SQL Server Part 1
    Understanding Columnstore Indexes in SQL Server Part 1
  • Add DBCC INPUTBUFFER to Your Performance Tuning Toolbox
    Add DBCC INPUTBUFFER to Your Performance Tuning Toolbox
  • It's All in the Name, Index Naming Conventions
    It's All in the Name, Index Naming Conventions
  • What’s a Key Lookup?
    What’s a Key Lookup?
  • Scooby Dooing Episode 9: The Case of the Artificially Intelligent Villain
    Scooby Dooing Episode 9: The Case of the Artificially Intelligent Villain
  • Contained Database – No more need for Server Level Logins
    Contained Database – No more need for Server Level Logins
  • DMV’s for the Beginner
    DMV’s for the Beginner
  • The Mystery of SQL Server 2025’s New Tricks - Scooby Dooing Episode 5
    The Mystery of SQL Server 2025’s New Tricks - Scooby Dooing Episode 5
  • SSRS Report Won’t Render in VS Preview
    SSRS Report Won’t Render in VS Preview
  • TIL: Microsoft Azure Part 2
    TIL: Microsoft Azure Part 2
Graceful Pro Theme by Optima Themes - 2026 ©
 

Loading Comments...