How to know what statistics are used on a given query?

  • How to know what statistics are used on a given query on SQL Server?

    Sivaprasad S - [ SIVA ][/url]http://sivasql.blogspot.com/[/url]

  • There's no way to tell that for certain. You can guess, based on the predicates in the query and the joins which ones will likely be used.

    Or, if you have a test database somewhere, drop all the stats, run the query and then see which ones were created, but that won't help for index statistics.

    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
  • The statistics that were considered interesting to the query optimiser are stored with the compiled plan, but this information is not exposed to users.

    The real question is, why do you want to know which statistics are relevant to a query compilation?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply