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

  • sivaprasad

    SSCertifiable

    Points: 6183

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

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

  • Gail Shaw

    SSC Guru

    Points: 1004484

    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
  • Paul White

    SSC Guru

    Points: 150442

    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 3 (of 3 total)

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