Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Low Cardinality estimate in Hash match operator

$
0
0
Hi Guys,Sorry to post this in 2014 forum, I did that because the problem seems to be fixed in the new cardinality estimator.I am trying to fix a performance problem with one of our reporting queries. I have just included the part of the query that is causing low estimate. This part is further joined with other tables and since the estimates for this one is so low further joins end up being nested loop and causing the query to run forever.select distinct nath.Transactionidfrom nath WHERE StatusId = 3 andDate IS NOT NULL andNOT EXISTS (SELECT 1 FROM nath WHERE nath.Transactionid= nath.TransactionidAND StatusId = 3AND HistoryId < nat.HistoryId) enter image description hereIn the above query the estimate for the hash match is only 1.17 but in reality there are 550K records coming out.For further trouble shooting I ran the exact same query on one of our SQL 2014 server and it produced correct results and the estimates was 557K on the hash match operator. I then tried trace flag 9481 to force the old cardinality estimator on 2014 and the estimates where back to 1.So I think the issue is something to do with old CE estimating self joins.I even tried trace flag 4199 on SQL 2008R2 but that did not help.Please let me know if there is anyway to fix this wrong estimate. Thanks

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images