SQL Server 2019 and the Approx_Count_Distinct function
Hi Guys, Today we continue with the speech of the new features of SQL 2019, if last time we talked about Batch mode on Rowstore , today we talk about another new feature: the function Approx_Count_Distinct . Enjoy the reading, mate! The Approx_Count_Distinct function Let's suppose for simplicity we take the same "movements" table used in the last post and already filled with 3 million rows. CREATE TABLE Moviments (ID INT IDENTITY(1,1), YEAR FLOAT , QTY FLOAT , PRICE FLOAT, CLASSIFICATORS VARCHAR(10)) Now suppose you want to know the number of items purchased for each classificators. Simple, you will say! just write this command: SELECT COUNT( DISTINCT CLASSIFICATORS) FROM MOVIMENTS True! However, it will not surprise you to know that this operation, which apparently seems to be so simple, instead requires many resources (and to read through all the rows of our table): Table 'Worktable...