title: Extrememly High Estimated Number of Rows in Execution Plan
body: <p><img src="https://i.stack.imgur.com/kNZNW.jpg" alt="enter image description here"></p>
  
  <p>I have a stored procedure running 10 times slower in production than in staging. I took at look at the execution plan and the first thing I noticed was the cost on Table Insert (into a table variable @temp) was 100% in production and 2% in staging. </p>
  
  <p>The estimated number of rows in production showed almost 200 million row! But in staging was only about 33.</p>
  
  <p>Although the production DB is running on SQL Server 2008 R2 while staging is SQL Server 2012 but I don't think this difference could cause such a problem.</p>
  
  <p>What could be the cause of such a huge difference?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Added the execution plan. As you can see, the large number of estimated rows shows up in Nested Loops (Inner Join) but all it does is a clustered index seek to another table. </p>
  
  <p><strong>UPDATED2</strong></p>
  
  <p>Link for the plan XML included
  <a href="https://onedrive.live.com/redir?resid=5D0A0244F4492D43!171&amp;authkey=!AFrU-MbBA-iFgkY&amp;ithint=file%2Cxml" rel="nofollow noreferrer">plan.xml</a></p>
  
  <p>And SQL Sentry Plan Explorer view (with estimated counts shown)</p>
  
  <p><img src="https://i.stack.imgur.com/jNNCp.png" alt="enter image description here"></p>