1

I remember reading once that it is possible to force SQL Server to assume a table is a certain size, or perhaps even override a statistics histogram, when compiling a query. Can someone explain how to do that, if it's possible?

To be clear: the purpose of this is to do what-if scenario analysis, outside of production, when writing queries. I am not talking about modifying the query itself or using query hints. (Examples of modifying the query and using query hints can be found in the answers to this question.)

1

You can use the UPDATE STATISTICS WITH ROWCOUNT and PAGECOUNT option

See here some examples : https://www.mssqltips.com/sqlservertip/2870/using-with-rowcount-and-pagecount-option-of-sql-server-update-statistics/ or https://sqlsunday.com/2016/02/27/update-statistics-with-rowcount/

  • 1
    Even when you're not sure, posting an answer gives you all the same options (and more!) as posting a comment. There's just no reason not to answer in an answer. Thanks for your cooperation. – Paul White Jun 12 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.