• OhioGuy (5/20/2016)


    Am I correct in saying that the statistics will NOT be updated, because A) SQL server does not treat truncates the same as inserts/deletes/updates, and B)~2000 inserts is nowhere near 20% of 32 million, so SQL server will still think the stats are fresh, even though they are way out of whack? That's my question #1.

    They'll get updated. Truncate sets the row count for the table back to 0 (but doesn't change the colmodctr as far as I'm aware), the next set of modifications adds to the rowmodctr again, then when something goes to use the table, colmodctr compared with rows in table to see if stats are out, and will almost certainly trigger an update.

    At least that's how 2008 (I think it was) worked. Can't remember the last time I played with this.

    Pull the query plans, they'll tell you what's going on with the row estimations. You can also easily check stats update data with the STATS_DATE() function

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass