Posts

Showing posts from December, 2024

Troubleshoot SQL Server Cardinality Estimate

Image
Today, I will show you why good cardinality estimate is essential for an efficient execution plan and how I troubleshoot inaccurate cardinality estimates. I will use the database StackOverflow2010 to demonstrate. INSERT 50,000 rows I insert 50,000 rows with OwnerUserID 26837 into the table. Assuming this is a real life workload! DECLARE   @date   AS   DATETIME   =   Getdate ( ) ; INSERT   INTO   posts              ( body ,               lastactivitydate ,               creationdate ,               score ,               viewcount ,               posttypeid , ...