Queries - List By Database
Gets a list of top queries by database.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/topQueries?api-version=2014-04-01
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
database
|
path | True |
string |
The name of the database. |
|
resource
|
path | True |
string |
The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. |
|
server
|
path | True |
string |
The name of the server. |
|
subscription
|
path | True |
string |
The subscription ID that identifies an Azure subscription. |
|
api-version
|
query | True |
string |
The API version to use for the request. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
OK |
Examples
List top queries
Sample request
GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/sqlcrudtest/databases/db1/topQueries?api-version=2014-04-01
Sample response
{
"value": [
{
"type": "Microsoft.Sql/servers/databases/topQueries",
"numberOfTopQueries": 1,
"aggregationFunction": "sum",
"executionType": "any",
"observedMetric": "cpu",
"observationStartTime": "2017-07-11T16:21:54.0916567Z",
"observationEndTime": "2017-07-12T16:21:54.0916567Z",
"intervalType": "PT1H",
"queries": [
{
"queryId": "19",
"intervals": [
{
"intervalStartTime": "2017-07-11T16:00:00",
"executionCount": 12,
"metrics": [
{
"name": "cpu",
"displayName": "Cpu",
"unit": "percentage",
"value": 0.000763888888888889
},
{
"name": "io",
"displayName": "Physical Io Reads",
"unit": "percentage",
"value": 0
},
{
"name": "logIo",
"displayName": "Log Writes",
"unit": "percentage",
"value": 0
},
{
"name": "memory",
"displayName": "Memory consumption",
"unit": "KB",
"value": 0
},
{
"name": "duration",
"displayName": "Query duration",
"unit": "microseconds",
"value": 3308
}
]
}
]
}
]
}
]
}
Definitions
| Name | Description |
|---|---|
|
Query |
The function that is used to aggregate each query's metrics. |
|
Query |
The execution type that is used to filter the query instances that are returned. |
|
Query |
A database query. |
|
Query |
A database query. |
|
Query |
The unit of measurement |
|
Query |
The type of metric to use for ordering the top metrics. |
|
Query |
A database query. |
|
Top |
A database query. |
|
Top |
Represents the response to a get top queries request. |
QueryAggregationFunction
The function that is used to aggregate each query's metrics.
| Value | Description |
|---|---|
| min | |
| max | |
| avg | |
| sum |
QueryExecutionType
The execution type that is used to filter the query instances that are returned.
| Value | Description |
|---|---|
| any | |
| regular | |
| irregular | |
| aborted | |
| exception |
QueryInterval
A database query.
| Name | Type | Description |
|---|---|---|
| executionCount |
number (int32) |
The number of times the query was executed during this interval. |
| intervalStartTime |
string (date-time) |
The start time of the measurement interval (ISO8601 format). |
| metrics |
The list of query metrics during this interval. |
QueryMetric
A database query.
| Name | Type | Description |
|---|---|---|
| displayName |
string |
The name of the metric for display in user interface |
| name |
string |
The name of the metric |
| unit |
The unit of measurement |
|
| value |
number (double) |
The measured value |
QueryMetricUnit
The unit of measurement
| Value | Description |
|---|---|
| percentage | |
| KB | |
| microseconds |
QueryObservedMetricType
The type of metric to use for ordering the top metrics.
| Value | Description |
|---|---|
| cpu | |
| io | |
| logio | |
| duration | |
| executionCount |
QueryStatistic
A database query.
| Name | Type | Description |
|---|---|---|
| intervals |
The list of query intervals. |
|
| queryId |
string |
The id of the query |
TopQueries
A database query.
| Name | Type | Description |
|---|---|---|
| aggregationFunction |
The function that is used to aggregate each query's metrics. |
|
| executionType |
The execution type that is used to filter the query instances that are returned. |
|
| intervalType |
string |
The duration of the interval (ISO8601 duration format). |
| numberOfTopQueries |
number (int32) |
The number of requested queries. |
| observationEndTime |
string (date-time) |
The end time for queries that are returned (ISO8601 format) |
| observationStartTime |
string (date-time) |
The start time for queries that are returned (ISO8601 format) |
| observedMetric |
The type of metric to use for ordering the top metrics. |
|
| queries |
The list of queries. |
TopQueriesListResult
Represents the response to a get top queries request.
| Name | Type | Description |
|---|---|---|
| value |
The list of top queries. |