Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table dbo.CS;
- drop table dbo.T;
- go
- create table dbo.CS(CS bit not null, index IX_CS clustered columnstore);
- create table dbo.T(I int not null, P int not null);
- create index IX_T_P on dbo.T(P) include(I);
- go
- declare @NumRows int;
- declare @NumPart int;
- set @NumRows = 100000;
- set @NumPart = 4
- insert into dbo.T(I, P)
- select top(@NumRows)
- row_number() over(order by(select null)),
- row_number() over(order by(select null)) % @NumPart
- from sys.columns as C1,
- sys.columns as C2,
- sys.columns as C3
- go
- set statistics io on;
- declare @I int;
- select @I = min(I) over(partition by P)
- from dbo.T
- left outer join dbo.CS on 0 = 1;
- set statistics io off;
- /*
- Result on my machine
- Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64)
- NumRows NumPart Logical reads in Worktable
- 100,000 4 2902
- 100,000 5 0
- 1,000,000 8 37535
- 1,000,000 9 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement