Use index recommendations

Index tuning persists the recommendations that it produces in a set of tables located under the intelligentperformance schema in the azure_sys database.

These recommendations can be read using the Index tuning page in Azure portal, or using the Azure CLI az postgres flexible-server index-tuning list-recommendations command.

However, none of those two methods reveal the text of the queries for which the recommendations were produced. This behavior is intentional, because the texts of the queries might contain sensitive information. Seeing the text of those statements should only be allowed to subjects with authorization to access the database. But it shouldn't be allowed to subjects who are only granted access to the instance of Azure Database for PostgreSQL flexible server, as an Azure resource.

Hence, if you need to read the text of the queries, you need to be granted permissions to connect to the database engine, so that you can execute queries to retrieve that information from two views available inside the intelligent performance of the azure_sys database.

Steps to list index recommendations

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

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

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

      Screenshot that shows the aspect of 'Index 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 'Index 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 'Index tuning' page when the feature is disabled and there are recommendations.

  3. If there are recommendations available, select on the View index recommendations summarization to access to the full list:

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

  4. The list shows all available recommendations with some details for each of them. 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 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 provided:

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

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

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

Steps to apply index recommendations

Index recommendations contain the SQL statement that you can execute to implement the recommendation.

The following section demonstrates how this statement can be obtained for a particular recommendation.

Once you have the statement, you can use any PostgreSQL client of your preference to connect to your server and apply the recommendation.

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

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

    Screenshot that shows the Index tuning menu option under the Intelligent Performance section, to disable index tuning.

  3. Assuming index tuning produced recommendations, select the View index recommendations summarization to access the list of available recommendations.

    Screenshot that shows the aspect of 'Index 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 for which you want to obtain the SQL statement, and select Copy SQL script.

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

    • Or select the name of the recommendation to show its Index 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 'Index recommendation details' page.