I have a complex query on a database with bad statistics and fragmented indices. What I'm puzzled by is that when I examine an actual query plan I get 54 M rows from a table scan on a table that has 23 K rows. Much further up the query plan this table is joined against itself (only 260 K rows out of 23 K). How is this possible?
Running some other queries or rebuilding indices and statistics makes this go away, I'm just trying to understand why this would happen.
I have reproduced this with SQL 2005 and SQL 2008 R2 on a restore of the same database.
Update: Yes, this is an actual plan. Number of rows is 20039 (not 23 K as mentioned above). This is one the the rightmost nodes.