你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Managed Database Queries - List By Query

按查询 ID 获取查询执行统计信息。

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics?api-version=2021-11-01
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics?startTime={startTime}&endTime={endTime}&interval={interval}&api-version=2021-11-01

URI 参数

名称 必需 类型 说明
databaseName
path True

string

数据库的名称。

managedInstanceName
path True

string

托管实例的名称。

queryId
path True

string

resourceGroupName
path True

string

包含该资源的资源组名称。 可以从 Azure 资源管理器 API 或门户获取此值。

subscriptionId
path True

string

用于标识 Azure 订阅的订阅 ID。

api-version
query True

string

要用于请求的 API 版本。

endTime
query

string

观察到的时间段的结束时间。

interval
query

QueryTimeGrainType

用于汇总指标值的时间步长。

startTime
query

string

观察到的时间段的开始时间。

响应

名称 类型 说明
200 OK

ManagedInstanceQueryStatistics

已成功检索查询文本。

Other Status Codes

错误响应:***

  • 404 SubscriptionDoesNotHaveServer - 找不到请求的服务器

  • 404 ServerNotInSubscriptionResourceGroup - 指定的服务器不存在于指定的资源组和订阅中。

  • 404 ResourceNotFound - 找不到请求的资源。

示例

Obtain query execution statistics
Obtain query execution statistics. Example with all request parameters.
Obtain query execution statistics. Minimal example with only mandatory request parameters.

Obtain query execution statistics

示例请求

GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/managedInstances/sqlcrudtest-4645/databases/database_1/queries/42/statistics?api-version=2021-11-01

示例响应

{
  "value": [
    {
      "properties": {
        "databaseName": "db1",
        "queryId": "35",
        "startTime": "03/01/2020 18:34:58",
        "endTime": "03/02/2020 18:34:58",
        "intervals": [
          {
            "intervalStartTime": "03/02/2020 08:00:00",
            "intervalType": "PT1H",
            "executionCount": 160,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 1.507638888888889E-05,
                "max": 2.5243055555555557E-05,
                "avg": 1.665347222222222E-05,
                "sum": 0.0026645555555555554,
                "stdev": 1.4894345929850385E-06
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 4373,
                "max": 18490,
                "avg": 5026.625,
                "sum": 804260,
                "stdev": 1487.3520882343225
              }
            ]
          },
          {
            "intervalStartTime": "03/02/2020 09:00:00",
            "intervalType": "PT1H",
            "executionCount": 20,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 2.3430555555555557E-05,
                "max": 0.00014645833333333332,
                "avg": 4.479774305555555E-05,
                "sum": 0.0008959548611111111,
                "stdev": 3.830118344204395E-05
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 6813,
                "max": 42289,
                "avg": 12963.2,
                "sum": 259264,
                "stdev": 11040.140794392071
              }
            ]
          },
          {
            "intervalStartTime": "03/02/2020 15:00:00",
            "intervalType": "PT1H",
            "executionCount": 80,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 1.8215277777777777E-05,
                "max": 2.764236111111111E-05,
                "avg": 1.9315538194444445E-05,
                "sum": 0.0015452430555555556,
                "stdev": 1.0716305801875179E-06
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 5264,
                "max": 7982,
                "avg": 5586.2625,
                "sum": 446901,
                "stdev": 310.4915757210727
              }
            ]
          },
          {
            "intervalStartTime": "03/02/2020 17:00:00",
            "intervalType": "PT1H",
            "executionCount": 80,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 1.7819444444444443E-05,
                "max": 2.782638888888889E-05,
                "avg": 1.9085373263888888E-05,
                "sum": 0.0015268298611111112,
                "stdev": 1.2309244108727927E-06
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 5147,
                "max": 8052,
                "avg": 5517.2,
                "sum": 441376,
                "stdev": 356.8763581410226
              }
            ]
          }
        ]
      },
      "id": "35",
      "type": "Microsoft.Sql/managedInstances/databases/queries/statistics"
    }
  ]
}

Obtain query execution statistics. Example with all request parameters.

示例请求

GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/managedInstances/sqlcrudtest-4645/databases/database_1/queries/42/statistics?startTime=03/01/2020 16:23:09&endTime=03/11/2020 14:00:00&interval=P1D&api-version=2021-11-01

示例响应

{
  "value": [
    {
      "properties": {
        "databaseName": "db1",
        "queryId": "28",
        "startTime": "03/01/2020 16:23:09",
        "endTime": "03/11/2020 14:00:00",
        "intervals": [
          {
            "intervalStartTime": "03/11/2020 00:00:00",
            "intervalType": "P1D",
            "executionCount": 1,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 0.0015934667245370371,
                "max": 0.0015934667245370371,
                "avg": 0.0015934667245370371,
                "sum": 0.0015934667245370371,
                "stdev": 0
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 4.224537037037037E-06,
                "max": 4.224537037037037E-06,
                "avg": 4.224537037037037E-06,
                "sum": 4.224537037037037E-06,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 8336,
                "max": 8336,
                "avg": 8336,
                "sum": 8336,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 11091296,
                "max": 11091296,
                "avg": 11091296,
                "sum": 11091296,
                "stdev": 0
              }
            ]
          }
        ]
      },
      "id": "28",
      "type": "Microsoft.Sql/managedInstances/databases/queries/statistics"
    }
  ]
}

Obtain query execution statistics. Minimal example with only mandatory request parameters.

示例请求

GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/managedInstances/sqlcrudtest-4645/databases/database_1/queries/42/statistics?interval=PT1H&api-version=2021-11-01

示例响应

{
  "value": [
    {
      "properties": {
        "databaseName": "db1",
        "queryId": "28",
        "startTime": "03/10/2020 14:00:30",
        "endTime": "03/11/2020 14:00:30",
        "intervals": [
          {
            "intervalStartTime": "03/11/2020 11:00:00",
            "intervalType": "PT1H",
            "executionCount": 1,
            "metrics": [
              {
                "name": "cpu",
                "displayName": "Cpu",
                "unit": "percentage",
                "value": 0,
                "min": 0.03824320138888889,
                "max": 0.03824320138888889,
                "avg": 0.03824320138888889,
                "sum": 0.03824320138888889,
                "stdev": 0
              },
              {
                "name": "io",
                "displayName": "Physical Io Reads",
                "unit": "percentage",
                "value": 0,
                "min": 0.0001013888888888889,
                "max": 0.0001013888888888889,
                "avg": 0.0001013888888888889,
                "sum": 0.0001013888888888889,
                "stdev": 0
              },
              {
                "name": "logIo",
                "displayName": "Log Writes",
                "unit": "percentage",
                "value": 0,
                "min": 0,
                "max": 0,
                "avg": 0,
                "sum": 0,
                "stdev": 0
              },
              {
                "name": "memory",
                "displayName": "Memory consumption",
                "unit": "KB",
                "value": 0,
                "min": 8336,
                "max": 8336,
                "avg": 8336,
                "sum": 8336,
                "stdev": 0
              },
              {
                "name": "duration",
                "displayName": "Query duration",
                "unit": "microseconds",
                "value": 0,
                "min": 11091296,
                "max": 11091296,
                "avg": 11091296,
                "sum": 11091296,
                "stdev": 0
              }
            ]
          }
        ]
      },
      "id": "28",
      "type": "Microsoft.Sql/managedInstances/databases/queries/statistics"
    }
  ]
}

定义

名称 说明
ManagedInstanceQueryStatistics

一个特定查询的执行统计信息

QueryMetricInterval

查询指标间隔的属性。

QueryMetricProperties

一个时间间隔内 topquery 指标的属性。

QueryMetricUnitType

指标的单位。

QueryStatistics
QueryTimeGrainType

间隔类型 (长度) 。

ManagedInstanceQueryStatistics

一个特定查询的执行统计信息

名称 类型 说明
nextLink

string

用于检索下一页结果的链接。

value

QueryStatistics[]

结果数组。

QueryMetricInterval

查询指标间隔的属性。

名称 类型 说明
executionCount

integer

此时间间隔内查询的执行计数。

intervalStartTime

string

指标间隔的开始时间 (ISO-8601 格式) 。

intervalType

QueryTimeGrainType

间隔类型 (长度) 。

metrics

QueryMetricProperties[]

此间隔的指标对象列表

QueryMetricProperties

一个时间间隔内 topquery 指标的属性。

名称 类型 说明
avg

number

在间隔内使用 avg () 聚合函数时的指标值。

displayName

string

适用于指标的 UI 名称。

max

number

在间隔内使用 max () 聚合函数时的指标值。

min

number

在间隔内使用 min () 聚合函数时的指标值。

name

string

指标的名称信息。

stdev

number

在间隔内使用 stdev 聚合函数时的指标值。

sum

number

在间隔内使用 sum () 聚合函数时的指标值。

unit

QueryMetricUnitType

指标的单位。

value

number

指标的值。

QueryMetricUnitType

指标的单位。

名称 类型 说明
KB

string

count

string

microseconds

string

percentage

string

QueryStatistics

名称 类型 说明
id

string

资源 ID。

name

string

资源名称。

properties.databaseName

string

在其中执行此查询的数据库的数据库名称。

properties.endTime

string

指标的结束时间 (ISO-8601 格式) 。

properties.intervals

QueryMetricInterval[]

包含适当指标数据的间隔列表

properties.queryId

string

在一个数据库) 中,唯一的查询 ID (唯一。

properties.startTime

string

指标的开始时间 (ISO-8601 格式) 。

type

string

资源类型。

QueryTimeGrainType

间隔类型 (长度) 。

名称 类型 说明
P1D

string

PT1H

string