Skip to content

Commit e47fcae

Browse files
authored
Merge pull request #177883 from mariyaali/master
added query-history-storage-analysis.md
2 parents 359eb8c + 011c613 commit e47fcae

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: Historical query storage and analysis in Azure Synapse Analytics
3+
description: Historic query analysis is one of the crucial needs of data engineers. Azure Synapse Analytics supports four main ways to analyze query history and performance. These include Query Store, DMVs, Azure Log Analytics, and Azure Data Explorer.
4+
author: mariyaali
5+
ms.author: mariyaali
6+
ms.reviewer: wiassaf
7+
ms.service: synapse-analytics
8+
ms.topic: conceptual
9+
ms.date: 10/28/2021
10+
ms.custom: template-concept
11+
---
12+
13+
# Historical query storage and analysis in Azure Synapse Analytics
14+
15+
Historic query analysis is one of the crucial needs of data engineers. Azure Synapse Analytics supports four main ways to analyze query history and performance. These include Query Store, DMVs, Azure Log Analytics, and Azure Data Explorer.
16+
17+
This article will show you how to use each of these options for your needs. Review use cases when it comes to analyzing query history, and the best method for each.
18+
19+
| **Customer need** | **Query Store** | **DMVs** | **Azure Log Analytics** | **Azure Data Explorer** |
20+
|------------- | --- | ----- | ------------- |-------------------|
21+
|**Out of the box solution** | Needs enabling | :heavy_check_mark: | Addition service required | Addition service required|
22+
|**Longer analysis periods** | 30 days | Up to 10000 rows of history | Customizable | Customizable|
23+
|**Crucial metrics availability** | Limited | :heavy_check_mark: | Limited | Customizable|
24+
|**Use SQL for analysis** | :heavy_check_mark: | :heavy_check_mark:| KQL needed | SQL support is limited|
25+
|||||
26+
27+
## Query Store
28+
29+
The Query Store feature provides insight on query plan choice and performance. It simplifies performance troubleshooting by helping you quickly find performance differences caused by query plan changes.
30+
31+
Query Store is not enabled by default for new Azure Synapse Analytics databases. To enable Query Store to run the following T-SQL command:
32+
33+
```sql
34+
ALTER DATABASE <database_name>
35+
SET QUERY_STORE = ON;
36+
```
37+
38+
For example:
39+
40+
```sql
41+
ALTER DATABASE [SQLPOOL1]
42+
SET QUERY_STORE = ON;
43+
```
44+
45+
You can run performance auditing and troubleshooting related tasks by finding last executed queries, execution counts, longest running queries, queries with maximum physical I/O leads. Please refer to [Monitoring Performance By Using the Query Store](/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store#performance) for sample queries.
46+
47+
Advantages:
48+
* 30 days of threshold for storage query data.
49+
* Data can be consumed in the same tool that you'd run the query in.
50+
51+
Known Limitation:
52+
* Scenarios for analysis are limited in Query Store for Azure Synapse when compared to using DMVs.
53+
54+
## DMVs
55+
56+
Dynamic Management Views (DMVs) are extremely useful when it comes to gathering information on query wait times, execution plans, memory, etc.
57+
It is highly recommended to label your query of interest to track it down later. For example:
58+
59+
```sql
60+
-- Query with Label
61+
SELECT *
62+
FROM sys.tables
63+
OPTION (LABEL = 'My Query');
64+
```
65+
66+
For more information on labeling your queries in Azure Synapse SQL, see [Use query labels in Synapse SQL](develop-label.md).
67+
68+
For more information on using DMVs to monitor your Azure Synapse Analytics workload, see [Monitor your dedicated SQL pool workload using DMVs](../sql-data-warehouse/sql-data-warehouse-manage-monitor.md?context=/azure/synapse-analytics/context/context). For documentation on catalog views specific to Azure Synapse Analytics, see [Azure Synapse Analytics Catalog Views](/sql/relational-databases/system-catalog-views/sql-data-warehouse-and-parallel-data-warehouse-catalog-views).
69+
70+
Advantages:
71+
* Data can be consumed in the same querying tool.
72+
* DMVs provide extensive options for analysis.
73+
74+
Known Limitations:
75+
* DMVs are limited to 10,000 rows of historic entries.
76+
* Views are reset when pool is paused/resumed.
77+
78+
## Log Analytics
79+
Log Analytics workspaces can be created easily in the Azure portal. For further instructions on how to connect Synapse with Log Analytics, see [Monitor workload - Azure portal](../sql-data-warehouse/sql-data-warehouse-monitor-workload-portal.md).
80+
81+
Like Azure Data Explorer, Log Analytics uses the Kusto Query Language (KQL). For more information about Kusto syntax, see [Kusto query overview](/data-explorer/kusto/query/index.md).
82+
83+
Along with configurable retention period, you choose the workspace you are specifically targeting to query in Log Analytics. Log Analytics gives you the flexibility to store data, run, and save queries.
84+
85+
Advantages:
86+
* Azure Log Analytics has a customizable log retention policy
87+
88+
Known Limitations:
89+
* Using KQL adds to the learning curve.
90+
* Limited views can be logged out of the box.
91+
92+
## Azure Data Explorer (ADX)
93+
94+
Azure Data Explorer (ADX) is a leading data exploration service. This service can be used to analyze historic queries from Azure Synapse Analytics. To setup an Azure Data Factory (ADF) pipeline to copy and store logs to ADX, see [Copy data to or from Azure Data Explorer](/data-factory/connector-azure-data-explorer.md). In ADX, you can run performant Kusto query to analyze your logs. You can combine other strategies here, for example to query and load DMV output to ADX via ADF.
95+
96+
Advantages:
97+
* ADX provides a customizable log retention policy.
98+
* Performant query execution against large amount of data, especially queries involving string search.
99+
100+
Known Limitation:
101+
* Using KQL adds to the learning curve.
102+
103+
## Next steps
104+
105+
- [Azure Data Explorer](/azure/data-explorer/)
106+
- [Azure Data Factory](/azure/data-factory/)
107+
- [Log Analytics in Azure Monitor](/azure/azure-monitor/logs/log-analytics-overview)
108+
- [Azure Synapse SQL architecture](overview-architecture.md)
109+
- [Get Started with Azure Synapse Analytics](../get-started.md)

articles/synapse-analytics/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ items:
500500
href: ./sql-data-warehouse/sql-data-warehouse-manage-monitor.md?context=/azure/synapse-analytics/context/context
501501
- name: Monitor your workload - portal
502502
href: ./sql-data-warehouse/sql-data-warehouse-monitor-workload-portal.md?context=/azure/synapse-analytics/context/context
503+
- name: Query history and analysis
504+
href: ./sql/query-history-storage-analysis.md
503505
- name: Manage workloads
504506
items:
505507
- name: Analyze your workload

0 commit comments

Comments
 (0)