Edit

Use autonomous tuning recommendations in Azure Database for PostgreSQL flexible server

Autonomous tuning stores its recommendations in tables under the intelligentperformance schema in the azure_sys database.

You can view these recommendations in the Autonomous tuning page in the Azure portal, or by using the Azure CLI commands az postgres flexible-server autonomous-tuning list-table-recommendations and az postgres flexible-server autonomous-tuning list-index-recommendations.

However, neither method shows the text of the queries for which the recommendations were made. This behavior is intentional, because the query texts might contain sensitive information. Only users with authorization to access the database should see the text of those statements. Users who are only granted access to the instance of Azure Database for PostgreSQL flexible server, as an Azure resource, shouldn't see the text.

If you need to read the text of the queries, you need permissions to connect to the database engine. You can then execute queries to retrieve that information from two views available inside the intelligent performance of the azure_sys database.

Note

The system automatically deletes recommendations 35 days after the last time it produces them. For this automatic deletion mechanism to work, autonomous tuning must be enabled.

Steps to list autonomous tuning recommendations

Use the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

  2. In the resource menu, under Intelligent Performance, select Autonomous tuning.

    • If the feature is enabled but no recommendations are produced yet, the screen looks like this:

      Screenshot that shows the aspect of 'Autonomous tuning' page when the feature is enabled but there aren't recommendations.

    • If the feature is disabled and it never produced recommendations in the past, the screen looks like this:

      Screenshot that shows the aspect of 'Autonomous tuning' page when the feature is disabled and there aren't recommendations.

    • If the feature is disabled but it was enabled before and produced recommendations, the screen looks like this:

      Screenshot that shows the aspect of 'Autonomous tuning' page when the feature is disabled and there are recommendations.

  3. If there are recommendations available for any of the five existing types, select the summarization card to access the full list of that specific type:

    Screenshot that shows the aspect of 'Autonomous tuning' page when there are recommendations, and the way to get to the full list for a given recommendation type.

  4. The list shows all available recommendations of that type, with some details for each recommendation. By default, the list is sorted by Last recommended in descending order, showing the most recent recommendations at the top. However, you can sort by any other column, and you can use the filtering box to reduce the list of items shown. Filtered items are those whose database, schema, or table names contain the text you provide:

    Screenshot that shows the aspect of 'Recommendations' page with several recommendations.

  5. To see further information about any specific recommendation, select the name of that recommendation. The Recommendation details pane opens on the right side of the screen and surfaces all available details about the recommendation:

    Screenshot that shows the aspect of 'Recommendation details' pane for one particular recommendation.

Steps to apply recommendations

Recommendations include the SQL statement that you can run to implement the recommendation.

The following section shows how to get this statement for a specific recommendation.

After you get the statement, use any PostgreSQL client you prefer to connect to your server and apply the recommendation.

Use the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

  2. In the resource menu, under Intelligent Performance, select Autonomous tuning.

    Screenshot that shows the Autonomous tuning menu option under the Intelligent Performance section, to disable autonomous tuning.

  3. If autonomous tuning generates recommendations, select one of the summarization cards to access the list of available recommendations of that type.

    Screenshot that shows the aspect of 'Autonomous tuning' page when there are recommendations, and the way to get to the full list.

  4. From the list of recommendations, either:

    • Select the ellipsis to the right of the recommendation name, for which you want to get the SQL statement, and select Copy SQL script.

      Screenshot that shows how to copy SQL statement from 'Recommendations' page.

    • Select the name of the recommendation to show its Recommendation details, and select the copy to clipboard icon in the SQL script text box to copy the SQL statement.

      Screenshot that shows how to copy SQL statement from 'Recommendation details' page.