Execution Plan in SQL Server?

92 Views Asked by At

In which situation estimated number of executions and actual number of execution differs? Could anybody list out the occasions?

Thanks In Advance

2

There are 2 best solutions below

0
On BEST ANSWER

In general, distribution statistics are responsible for cardinality estimates. In addition to said by TomTom, until very recently SQL Server has always assumed that table variables contain exactly 1 row. Needless to say, sometimes this resulted in an execution plan being horribly wrong - ganz falsch, practically.

If you use table variables that have a lot of rows, switch to at least 2012 and set a special trace flag that enables correct estimate: http://support.microsoft.com/kb/2952444

0
On
  • Shitty statistics which simply do not match reality because they are outdated.

  • Complex queries where the math behind assumptions goes wrong. Statistics entries are always simplified (A histogram) and some values may not fit into it.

Both can have part in it.