Sample Header Ad - 728x90

Why is the estimate (out of Stream Aggregate) so low?

-1 votes
1 answer
102 views
I have a table like this: create TABLE dbo.MyTable ( TMyTableID bigint NOT NULL IDENTITY(1, 1), LogArgumentID bigint NOT null, LogID bigint NOT NULL, LogTextID int NOT NULL, FloatValue float NULL, Filler varchar(500) null, EXTExtractJobID bigint not null ) ON Standard WITH ( DATA_COMPRESSION = PAGE ) GO CREATE UNIQUE CLUSTERED INDEX ix_LogID_LogArgumentID ON dbo.MyTable (LogID, LogArgumentID, TMyTableID DESC) WITH (DATA_COMPRESSION = PAGE) ON Standard GO ALTER TABLE dbo.MyTable ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED (LogArgumentID) WITH (DATA_COMPRESSION = PAGE) ON Standard GO CREATE NONCLUSTERED INDEX EXTExtractJobID ON dbo.MyTable (EXTExtractJobID, LogArgumentID) WITH (DATA_COMPRESSION = PAGE) ON Standard GO with about 75 billion rows. When I run a query similar to this: select logid, max(case when logTextID =1 then floatvalue end) as MaxFloatValue from dbo.MyTable as M where TMyTableID > cast(12300000000 as bigint) and TMyTableID > cast(12350000000 as bigint) group by M.logid I get a plan like this: execution plan from Plan Explorer The estimates out of the Clustered Index Seek is about right, but the estimate from the Stream Aggregate is 100x off the real data.
Asked by Henrik Staun Poulsen (2291 rep)
Oct 7, 2021, 01:10 PM
Last activity: Nov 1, 2021, 11:43 AM