7/10/2023 0 Comments Sql server datediffGraphical plan for DATEDIFF(MONTH, GETDATE(), 0) queryīut the estimated costs are out of whack – note how much higher the estimated costs are for the first query, which only returns 50 rows, compared to the second query, which returns 15,000 rows!Īnd the Top Operations tab shows that the first query (looking for ) estimated that it would find 15,000 rows, when in actuality it only found 50 the second query shows the opposite: it expected to find 50 rows matching, but found 15,000. Graphical plan for DATEDIFF(MONTH, 0, GETDATE()) query ![]() DateTest WHERE CreateDate = DATEADD ( MONTH, DATEDIFF ( MONTH, GETDATE ( ), 0 ), 0 ) DateTest WHERE CreateDate = DATEADD ( MONTH, DATEDIFF ( MONTH, 0, GETDATE ( ) ), 0 ) SELECT /* Query 2 */ COUNT ( * ) FROM dbo. SELECT /* Query 1 */ COUNT ( * ) FROM dbo.
0 Comments
Leave a Reply. |