Skip to content

Commit d8bfb9a

Browse files
Move and consolidate examples (#36406)
Co-authored-by: Dimitri Furman <dfurman@microsoft.com>
1 parent 6f06e57 commit d8bfb9a

1 file changed

Lines changed: 37 additions & 21 deletions

File tree

azure-sql/database/metrics-diagnostic-telemetry-logging-streaming-export-configure.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,11 @@ The following tables document the telemetry details available for all logs. For
512512
| `ElasticPoolName_s` | Name of the elastic pool for the database, if any |
513513
| `DatabaseName_s` | Name of the database |
514514
| `ResourceId` | Resource URI |
515-
| `query_hash_s` | Query hash |
516-
| `query_plan_hash_s` | Query plan hash |
515+
| `query_hash_s` <sup>1</sup> | Query hash |
516+
| `query_plan_hash_s` <sup>1</sup> | Query plan hash |
517517
| `statement_sql_handle_s` | Statement sql handle |
518-
| `interval_start_time_d` <sup>1</sup> | Internal identifier for the start of the statistics interval. |
519-
| `interval_end_time_d` <sup>1</sup> | Internal identifier for the end of the statistics interval. |
518+
| `interval_start_time_d` <sup>2</sup> | Internal identifier for the start of the statistics interval. |
519+
| `interval_end_time_d` <sup>2</sup> | Internal identifier for the end of the statistics interval. |
520520
| `logical_io_writes_d` | Total number of logical IO writes |
521521
| `max_logical_io_writes_d` | Max number of logical IO writes per execution |
522522
| `physical_io_reads_d` | Total number of physical IO reads |
@@ -542,7 +542,9 @@ The following tables document the telemetry details available for all logs. For
542542
| `query_id_d` | ID of the query in Query Store |
543543
| `plan_id_d` | ID of the plan in Query Store |
544544

545-
<sup>1</sup> Use the [example Kusto query](#examples) to convert this value into a useable timestamp.
545+
<sup>1</sup> To find matching queries and query plans in Query Store, see [Find matching queries and query plans in Query Store](#b-find-matching-queries-and-query-plans-in-query-store) later in this article.
546+
547+
<sup>2</sup> To convert this value into a useable timestamp, see [Convert the interval start and end times to datetime values](#a-convert-the-interval-start-and-end-times-to-datetime-values) later in this article.
546548

547549
For more information, see [sys.query_store_runtime_stats](/sql/relational-databases/system-catalog-views/sys-query-store-runtime-stats-transact-sql).
548550

@@ -573,16 +575,18 @@ For more information, see [sys.query_store_runtime_stats](/sql/relational-databa
573575
| `total_query_wait_time_ms_d` | Total wait time of the query on the specific wait category |
574576
| `max_query_wait_time_ms_d` | Max wait time of the query in individual execution on the specific wait category |
575577
| `query_param_type_d` | 0 |
576-
| `query_hash_s` | Query hash in Query Store |
577-
| `query_plan_hash_s` | Query plan hash in Query Store |
578+
| `query_hash_s` <sup>1</sup> | Query hash in Query Store |
579+
| `query_plan_hash_s` <sup>1</sup> | Query plan hash in Query Store |
578580
| `statement_sql_handle_s` | Statement handle in Query Store |
579-
| `interval_start_time_d` <sup>1</sup> | Internal identifier for the start of the statistics interval. |
580-
| `interval_end_time_d` <sup>1</sup> | Internal identifier for the end of the statistics interval. |
581+
| `interval_start_time_d` <sup>2</sup> | Internal identifier for the start of the statistics interval. |
582+
| `interval_end_time_d` <sup>2</sup> | Internal identifier for the end of the statistics interval. |
581583
| `count_executions_d` | Count of executions of the query |
582584
| `query_id_d` | ID of the query in Query Store |
583585
| `plan_id_d` | ID of the plan in Query Store |
584586

585-
<sup>1</sup> Use the [example Kusto query](#examples) to convert this value into a useable timestamp.
587+
<sup>1</sup> To find matching queries and query plans in Query Store, see [Find matching queries and query plans in Query Store](#b-find-matching-queries-and-query-plans-in-query-store) later in this article.
588+
589+
<sup>2</sup> To convert this value into a useable timestamp, see [Convert the interval start and end times to datetime values](#a-convert-the-interval-start-and-end-times-to-datetime-values) later in this article.
586590

587591
For more information, see [sys.query_store_wait_stats](/sql/relational-databases/system-catalog-views/sys-query-store-wait-stats-transact-sql).
588592

@@ -610,8 +614,10 @@ For more information, see [sys.query_store_wait_stats](/sql/relational-databases
610614
| `error_number_d` | Error code |
611615
| `Severity` | Severity of the error |
612616
| `state_d` | State of the error |
613-
| `query_hash_s` | Query hash of the failed query, if available |
614-
| `query_plan_hash_s` | Query plan hash of the failed query, if available |
617+
| `query_hash_s` <sup>1</sup> | Query hash of the failed query, if available |
618+
| `query_plan_hash_s` <sup>1</sup> | Query plan hash of the failed query, if available |
619+
620+
<sup>1</sup> To find matching queries and query plans in Query Store, see [Find matching queries and query plans in Query Store](#b-find-matching-queries-and-query-plans-in-query-store) later in this article.
615621

616622
For more information, see [Database Engine events and errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
617623

@@ -664,8 +670,10 @@ For more information about database wait statistics, see [sys.dm_os_wait_stats](
664670
| `DatabaseName_s` | Name of the database |
665671
| `ResourceId` | Resource URI |
666672
| `error_state_d` | A numeric state value associated with the query timeout (an [attention](/sql/relational-databases/errors-events/mssqlserver-3617-database-engine-error) event) |
667-
| `query_hash_s` | Query hash, if available |
668-
| `query_plan_hash_s` | Query plan hash, if available |
673+
| `query_hash_s` <sup>1</sup> | Query hash, if available |
674+
| `query_plan_hash_s` <sup>1</sup> | Query plan hash, if available |
675+
676+
<sup>1</sup> To find matching queries and query plans in Query Store, see [Find matching queries and query plans in Query Store](#b-find-matching-queries-and-query-plans-in-query-store) later in this article.
669677

670678
#### Blockings dataset
671679

@@ -742,21 +750,17 @@ For more information about database wait statistics, see [sys.dm_os_wait_stats](
742750
| `Event_s` | Type of Automatic tuning event |
743751
| `Timestamp_t` | Last updated timestamp |
744752

745-
The `query_hash_s` and `query_plan_hash_s` properties appear as numeric values. To find matching queries and query plans in [Monitor performance by using the Query Store](/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store), use the following T-SQL expression. It converts numeric hash values to binary hash values used in [sys.query_store_query](/sql/relational-databases/system-catalog-views/sys-query-store-query-transact-sql) and [sys.query_store_plan](/sql/relational-databases/system-catalog-views/sys-query-store-plan-transact-sql):
746753

747-
```sql
748-
SELECT CAST(CAST(hash_value as BIGINT) AS BINARY(8));
749-
```
750-
751-
Replace the `hash_value` placeholder with the actual `query_hash_s` or `query_plan_hash_s` numeric value.
752754

753755
#### Intelligent Insights dataset
754756

755757
For more information, see [Use the Intelligent Insights performance diagnostics log of Azure SQL Database and Azure SQL Managed Instance performance issues](intelligent-insights-use-diagnostics-log.md).
756758

757759
## Examples
758760

759-
The following Kusto query converts the `interval_start_time_d` and `interval_end_time_d` columns in the [Query Store runtime statistics](#query-store-runtime-statistics) and [Query Store wait statistics](#query-store-wait-statistics) datasets from internal values into `datetime` values.
761+
### A. Convert the interval start and end times to datetime values
762+
763+
The following Kusto expression converts the `interval_start_time_d` and `interval_end_time_d` columns in the [Query Store runtime statistics](#query-store-runtime-statistics) and [Query Store wait statistics](#query-store-wait-statistics) datasets from internal values into `datetime` values.
760764

761765
```kusto
762766
| extend interval_start_time_date = interval_start_time_d / 4294967296,
@@ -767,6 +771,18 @@ The following Kusto query converts the `interval_start_time_d` and `interval_end
767771
interval_end_date_time = datetime(1900-1-1) + time(1d) * interval_end_time_date + time(1s) * (interval_end_time_time / 300.0)
768772
```
769773

774+
### B. Find matching queries and query plans in Query Store
775+
776+
The `query_hash_s` and `query_plan_hash_s` properties appear as numeric values in the Query Store [runtime](#query-store-runtime-statistics) and [wait](#query-store-wait-statistics) statistics, and the [Errors](#errors-dataset) and [Time-outs](#time-outs-dataset) datasets.
777+
778+
To find matching queries and query plans in [Query Store](/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store), use the following T-SQL expression. It converts numeric hash values to binary hash values used in [sys.query_store_query](/sql/relational-databases/system-catalog-views/sys-query-store-query-transact-sql) and [sys.query_store_plan](/sql/relational-databases/system-catalog-views/sys-query-store-plan-transact-sql).
779+
780+
```sql
781+
SELECT CAST(CAST(<hash_value> as BIGINT) AS BINARY(8));
782+
```
783+
784+
Replace `<hash_value>` with the actual `query_hash_s` or `query_plan_hash_s` numeric value.
785+
770786
## Next steps
771787

772788
To learn how to enable logging and to understand the metrics and log categories supported by the various Azure services, see:

0 commit comments

Comments
 (0)