SQL Server, the "Group By" competition: from 30 seconds to 56 milliseconds
Hi Guys, In the last posts we spoken of all the teory begin the new features of SQL 2019. Today it's time to get to work! I propose you an exercise on which you can also try your hand at home . Given a Query it will be necessary to write it in order to make it as fast as possible . All the techniques we have said up to now are valid. Given a table containing movements what we want to obtain is the number of the various classifiers. If you think about it it is a very common request. I will propose some solutions but I expect your solutions! Ready? Let the "Group by" Race begin As a data structure we have a table called Moviments: CREATE TABLE [dbo].[Movements]( [Id] [int] IDENTITY (1,1) NOT NULL, [Qty] [float] NULL, [Price] [float] NULL, [Classifiers] [varchar](10) NULL ) ON [PRIMARY] GO CREATE CLUSTERED INDEX CI_MOVEMENTS_ID ON Movements(ID) A clustered index (CI) is defined on the column Id . For this example we fill our table with 50,000,000 records using the c...