Table statistics and histogram
get_table_statisticsLists optimizer statistics for a table or indexed view—columns, last update, rows, samples, and modifications—to diagnose inaccurate estimates or changed query plans.
Instructions
Lists the optimizer statistics of one table or indexed view: for each, its columns, when it was last updated, rows and rows sampled, modifications since then and how many remain before an automatic update (null for NORECOMPUTE, with automatic updates off, for hypothetical indexes, and for incremental or never-built statistics). With 'statistic', also that statistic's histogram and density vector; with 'value', where that value falls in the histogram, and only the steps around it. Use it when an estimate looks wrong or a plan changed, to see what the optimizer was told about the data without reading it; for the real distribution use get_data_profile, which scans the table, and for the settings that decide automatic updates use get_optimizer_settings. The contents need SELECT on the table; each statistic says whether the login could read them.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>",
"table": "<table>"
},
"name": "get_table_statistics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table or indexed view name, bare, with no schema prefix. Example: 'GenericSecurity' | |
| value | No | A value of the statistic's first column, to see where it falls in the histogram: on a step, inside one, below the first or above the last. Needs 'statistic'. Write dates in ISO 8601 and binary in 0x hexadecimal. It is taken as written, spaces included, so in a text column ' ' finds the empty string. A value the conversion to the column's type would change (text too long for it, more decimal places than it keeps, a time finer than it holds) is refused rather than looked up as another. Example: '2026-11-27' | |
| schema | No | Table schema. Empty searches every schema, and fails naming them when the name exists in more than one. Example: 'Feeder' | |
| database | Yes | Name of the database as registered in the configuration. | |
| statistic | No | Name of one statistic, as this tool lists it, to also return its histogram and density vector. Empty returns the list only. Example: 'IX_Price_ReferenceDate' |