|
| 1 | +--- |
| 2 | +title: "SET RECOMMENDATIONS (Transact-SQL)" |
| 3 | +description: "SET RECOMMENDATIONS enables or disables the Azure Synapse distribution advisor for the current session." |
| 4 | +author: mariyaali |
| 5 | +ms.author: mariyaali |
| 6 | +ms.reviewer: xiaoyul, wiassaf |
| 7 | +ms.date: 07/16/2023 |
| 8 | +ms.service: synapse-analytics |
| 9 | +ms.topic: reference |
| 10 | +f1_keywords: |
| 11 | + - "SET RECOMMENDATIONS" |
| 12 | + - "RECOMMENDATIONS" |
| 13 | +helpviewer_keywords: |
| 14 | + - "SET RECOMMENDATIONS" |
| 15 | + - "RECOMMENDATIONS" |
| 16 | +dev_langs: |
| 17 | + - "TSQL" |
| 18 | +monikerRange: "=azure-sqldw-latest" |
| 19 | +--- |
| 20 | +# SET RECOMMENDATIONS (Transact-SQL) |
| 21 | + |
| 22 | +[!INCLUDE [asa](../../includes/applies-to-version/asa-dedicated-sqlpool-only.md)] |
| 23 | + |
| 24 | +Enables or disables the Azure Synapse distribution advisor for the current session. For instructions and samples on the use of the distribution advisor, see [Distribution Advisor in Azure Synapse SQL](/azure/synapse-analytics/sql/distribution-advisor). |
| 25 | + |
| 26 | +> [!NOTE] |
| 27 | +> Distribution Advisor is currently in preview for Azure Synapse Analytics. Preview features are meant for testing only and should not be used on production instances or production data. As a preview feature, Distribution Advisor is subject to undergo changes in behavior or functionality. Please also keep a copy of your test data if the data is important. |
| 28 | + |
| 29 | + :::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) |
| 30 | + |
| 31 | +## Syntax |
| 32 | + |
| 33 | +```syntaxsql |
| 34 | +SET RECOMMENDATIONS { ON | OFF }; |
| 35 | +``` |
| 36 | + |
| 37 | +## Arguments |
| 38 | + |
| 39 | +#### ON |
| 40 | +Enables Distribution Advisor for the current client session. Subsequently run queries will be taken into consideration for distribution strategy recommendations. |
| 41 | + |
| 42 | +#### OFF |
| 43 | +Turns Distribution Advisor OFF for the current client session. Returns advice as a string. |
| 44 | + |
| 45 | +## Remarks |
| 46 | + |
| 47 | +Applies to [!INCLUDE [ssSDW](../../includes/ssazuresynapse_sqlpool_only.md)] only. |
| 48 | + |
| 49 | +Run this command when connected to a user database. |
| 50 | + |
| 51 | +## Permissions |
| 52 | + |
| 53 | +Requires membership in the public role. |
| 54 | + |
| 55 | +## Examples |
| 56 | + |
| 57 | +Following example will return distribution recommendation on selected TPC-DS queries. TPC-DS is an industry standard benchmark for analytical decision support workloads. |
| 58 | + |
| 59 | +First, begin the distribution advisor recommendation collection and run sample queries. |
| 60 | + |
| 61 | +```sql |
| 62 | +-- Step 1: Turn the distribution advisor ON for the current client session |
| 63 | +SET RECOMMENDATIONS ON; |
| 64 | +GO |
| 65 | + |
| 66 | +-- <insert your queries here, up to 100> |
| 67 | +SELECT ss_store_sk, COUNT(*) FROM store_sales, store WHERE ss_store_sk = s_store_sk GROUP BY ss_store_sk; |
| 68 | + |
| 69 | +SELECT cs_item_sk, COUNT(*) FROM catalog_sales, item WHERE cs_item_sk = i_item_sk AND i_manufact_id > 100 GROUP BY cs_item_sk; |
| 70 | + |
| 71 | +SELECT * FROM dbo.reason; |
| 72 | + |
| 73 | +-- Turn the distribution advisor OFF for the current client session. |
| 74 | +SET RECOMMENDATIONS OFF; |
| 75 | +GO |
| 76 | +``` |
| 77 | + |
| 78 | +Collect recommendations from the dynamic management view `sys.dm_pdw_distrib_advisor_results` for the current session. For example: |
| 79 | + |
| 80 | +```sql |
| 81 | + |
| 82 | +-- Step 2: view advice generated for the above workload |
| 83 | +DECLARE @sessionid nvarchar(100), @recommendation nvarchar(max); |
| 84 | +SELECT @sessionid = SESSION_ID(); |
| 85 | +SELECT @recommendation = recommendation FROM sys.dm_pdw_distrib_advisor_results WHERE session_id = @sessionid; |
| 86 | +SELECT @recommendation; |
| 87 | +GO |
| 88 | +``` |
| 89 | + |
| 90 | +## Next steps |
| 91 | + |
| 92 | +- [Distribution Advisor in Azure Synapse SQL](/azure/synapse-analytics/sql/distribution-advisor) |
0 commit comments