SQL query plan overestimation

LukaszT 2014-03-04 10:49:16

Do you have any idea why SQL is estimating so huge amount of rows and data size in milions of TB? Database has only 20GB.
Thanks in advance.
Lukasz

SQLkiwi 2014-03-04 13:25:31
Most of your joins are many-to-many:

Example join

In that example, inputs of 31,672 and 20,569 rows are estimated to produce 12,666,400 rows when joined. You should check your join conditions carefully, and also the database design to ensure you have uniqueness enforced where it should be. It's hard to be specific based on an anonymized plan, but those are the usual causes.