Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to script out all indexes created by azure automatic tuning in multiple azure sql databases?

Azure automatic tuning was just enabled on multiple databases and I would like to get all index creation scripts which was successfully implemented by azure auto tuning in multiple databases. Is there a good way scrip out all indexes at one's with some PowerShell or sql?

I know I can View scripts in recommendations window for every new index and script out manually one by one from there, but it's not convenient as there is multiple databases and lot's now indexes.

like image 869
Tadas Bublys Avatar asked Sep 12 '25 20:09

Tadas Bublys


1 Answers

Index recommendations are captured in the sys.dm_db_tuning_recommendations DMV even if the CREATE and DROP index options are not enabled. You can script what’s captured in the DMV and automate implementation of recommendations,

If you manually implement the recommendation using scripts, SQL Server does not perform any validation. If you implement the recommendation via the Portal (using the Apply button) or REST API, then it will be executed as if it were an automatic action, and validation will be performed (and the index could be automatically reverted if there’s a regression).

like image 161
Alberto Morillo Avatar answered Sep 15 '25 08:09

Alberto Morillo