2 ms·
It's been while since I have spent time with MSSQL, but I remember seeing this with sprocs and cardinality. The sproc would compile with 1 plan that dealt with
by matwood 10y ago
It's been while since I have spent time with MSSQL, but I remember seeing this with sprocs and cardinality. The sproc would compile with 1 plan that dealt with tables with little data. The plan would not always get updated as the tables fill with data.
The underlying reason is that as data changes the plan changes. For example, on a small table, it is faster/more efficient to do a table scan than go to the index and then to the table for data. At some threshold this changes. If table size can change the plan, then the query itself could also need changing as the table grows, indexes grow, and differing index cardinality emerges.