Flushes statistics from in-memory storage to the systabstats and sysstatistics system tables.
sp_flushstats [objname]
sp_flushstats titles
When you do not specify a table with the objname parameter, sp_flushstats acts at the database level.
Some statistics in the systabstats table are updated in in-memory storage locations and flushed to systabstats periodically, to reduce overhead and contention on systabstats.
If you query systabstats using SQL, executing sp_flushstats guarantees that in-memory statistics are flushed to systabstats.
The optdiag command always flushes in-memory statistics before displaying output.
The statistics in sysstatistics are changed only by data definition language commands and do not require the use of sp_flushstats.
The in-memory datachange counters are persistently stored in sysstatistics. These are flushed to disk when sp_flushstats is executed.
The permission checks for sp_flushstats differ based on your granular permissions settings.
Setting | Description |
---|---|
Enabled | With granular permissions enabled, you must be a user with monitor qp performance privilege. |
Disabled | With granular permissions disabled, you must be a user with sa_role. |
Values in event and extrainfo columns from the sysaudits table are:
Information | Values |
---|---|
Event | 38 |
Audit option | exec_procedure |
Command or access audited | Execution of a procedure |
Information in extrainfo |
|