Friday, March 30, 2018

Azure SQL Database – Automatic Index Tuning


Introduction: -

We live in an era of “Automation”.  Planes run on auto pilot mode, cars will soon be auto driven, so why not have auto indexed databases? This article will discuss the automatic index tuning feature available in Azure SQL Database.

Problem Statement:

Application development is moving at a rapid pace and its very common for application teams to develop a template database design and deliver it to multiple customers.  It is even more common in cloud where solutions are delivered as “software as a service” and it is way too challenging for application development team to analyze the workload of individual database, design specific indexes for them and tune them.

Automatic tuning in Azure SQL Database

Azure SQL Database, the cloud Platform as a service (PAAS) offering of SQL Server has attempted to address the above problem by introducing “Automatic tuning”. As of date, “automatic tuning” has the following features

·         Automatic plan correction – Plan regressions or sudden change in query plan resulting in performance degradation are tracked and last good plan available is forced. Automatic plan correction is already well explained over here

·         Automatic Index Tuning:  Automatic index tuning feature of Azure SQL Database will study the workload executed against the database, identify useful indexes and create them automatically. Automatic index tuning will also drop indexes that are unused over 93 days or any duplicate indexes present.

How to enable automatic index tuning

Once logged in to Azure Portal (portal.azure.com) one can enable the same by navigating to SQL Databases-> Click on the database -> Automatic tuning


·         Force plan -> Enables Automatic Plan Correction
        ·         Create / Drop Index -> enables automatic index tuning

Features can be enabled at server level and can be inherited at the database level as well.

TSQL Script for enabling automatic index tuning provided below
ALTER DATABASE DBName
          SET AUTOMATIC_TUNING (CREATE_INDEX = ON, 
      DROP_INDEX = ON)

Example:

To test how Auto Indexing works, following things were performed
·         A sample database with 5 tables with no indexes was created
·         10 to 15 select queries against the tables were executed repeatedly few thousand times over 3 to 4 hours
·         After one day, automatic indexing found the recommendations and rolled them out when there was less or no workload on the database.  Auto Indexing requires minimum one day of monitoring to identify recommendations
 This can be verified on Azure Portal by clicking on the “Database name” -> “Performance Recommendation”


The same can also be verified via the DMV sys.dm_db_tuning_recommendations, documented clearly over here
Key pointers of Automatic Index Tuning

·         Indexing recommendations are obtained using advanced artificial intelligence rules applied on the monitored workload. The recommendations are expected to be lot more accurate than earlier missing index recommendations from SSMS
·         The best part of the feature is it is non-blocking during the rollout of new indexes. 
·         Index changes wouldn’t be rolled out and will be postponed, if DTU usage was above 80% anytime in the last 20 minutes
·         Automatically created indexes don’t enforce any dependency on the columns. When the column with automatically created index is dropped, index is dropped as well
·         Auto created indexes can be tracked via sys.indexes – auto_created column
Learn – Adapt - Verify

One of the key features of Automatic Index tuning is the ability to monitor the impact of the changes done via automatic tuning. Azure SQL Database closely monitors the automatically created or dropped indexes and verifies if it has achieved the desired performance improvement. If it doesn’t then the change is automatically reverted to prevent any negative impact to the database. The reverted changes can be tracked from sys.dm_db_tuning_recommendations DMV as well.


Suggested enhancements



·         Automatic indexing is available only as an Azure SQL Database feature and is not available on SQL Server on premise. If would be wonderful if the feature could be extended to on premise SQL Server.
·         Automatic Index tuning should be extended to fixing fragmentation issues of the indexes as well.
Conclusion
 Automatic Index Tuning does simplify one of the major tasks of a database administrator and a developer. Automatic Index Tuning may not be 100% perfect to get the choices correct all the time but it is certainly a step in the right direction. Expect Microsoft to release more of such features in the days to come not just in indexing but also all areas of database maintenance

44 comments:

  1. I'm very much inspired when I've visited your blog. Your blog is really informative. Hope you will continue with the new article.

    http://tutorialabc.com

    ReplyDelete
  2. I'm very much inspired when I've visited your blog. Your blog is really informative. Hope you will continue with the new article.

    tutorialabc.com

    ReplyDelete
  3. I love this blog . This is one of the best blog i ever seen. It's all about what i'm searching for. I love to read this blog again and again . Every time i enter this blog i get something new. This blog inspire me to write new blog. I write a blog name http://tutorialabc.com. It's about sql,c#,net etc

    ReplyDelete

  4. hi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up. best sap simple finance online training institute in hyderabad

    ReplyDelete
  5. Thanks for sharing this useful article. Are you searching the correct partner to check Database Backup and Restore services? Try this company Database Backup and Restore services in usa

    ReplyDelete
  6. I’m not that much of a internet reader to be honest but your blogs really nice, keep it up! I'll go ahead and bookmark your website to come back in the future. Cheers epicor baq

    ReplyDelete
  7. You shared very interesting article and i really appreciate it. Keep going!!
    I am a data analyst and providing data analytics course in saket

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Good information I loved it
    Sanjary Kids is one of the best play school and preschool in Hyderabad,India. The motto of the Sanjary kids is to provide good atmosphere to the kids.Sanjary kids provides programs like Play group,Nursery,Junior KG,Serior KG,and provides Teacher Training Program.We have the both indoor and outdoor activities for your children.We build a strong value foundation for your child on Psychology and Personality development.
    Preschool in hyderabad

    ReplyDelete
  10. Good blog information by the author
    Sanjary Academy provides excellent training for Piping design course. Best Piping Design Training Institute in Hyderabad, Telangana. We have offer professional Engineering Course like Piping Design Course,QA / QC Course,document Controller course,pressure Vessel Design Course, Welding Inspector Course, Quality Management Course, #Safety officer course.
    Piping Design Course in India­

    ReplyDelete
  11. Good blog information of the author provided

    Pressure Vessel Design Course is one of the courses offered by Sanjary Academy in Hyderabad. We have offer professional Engineering Course like Piping Design Course,QA / QC Course,document Controller course,pressure Vessel Design Course,Welding Inspector Course, Quality Management Course, #Safety officer course.
    Document Controller course
    Pressure Vessel Design Course
    Welding Inspector Course
    Safety officer course
    Quality Management Course
    Quality Management Course in India

    ReplyDelete
  12. Nice Article
    Sanjary kids is the best playschool, preschool in Hyderabad, India. Start your play school,preschool in Hyderabad with sanjary kids. Sanjary kids provides programs like Play group,Nursery,Junior KG,Serior KG,and Teacher Training Program.
    play school in hyderabad, India
    Preschool in hyderabad, India
    Preschool teacher training course in hyderabad, India
    pre and primary teacher training course in hyderabad,India
    early childhood teacher training course in hyderabad, India

    ReplyDelete
  13. Nice Information
    Best QA / QC Course in India, Hyderabad. sanjaryacademy is a well-known institute. We have offer professional Engineering Course like Piping Design Course, QA / QC Course,document Controller course,pressure Vessel Design Course, Welding Inspector Course, Quality Management Course, #Safety officer course.
    QA / QC Course
    QA / QC Course in india
    QA / QC Course in hyderabad

    ReplyDelete
  14. I literally enjoyed to read your blog post. thanks for sharing such a informative content.
    Oceanapart technologies - databackup & transfer

    ReplyDelete
  15. Thanks for sharing this blog.This article gives lot of information.
    Azure Development Online Training

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Thanks that was really a wonderful content.
    We are the best waterproofing services in Hyderabad.We are providing all kinds of leakage services which includes bathroom,roof,wash area,water tank,wall cracks,kitchen leakage services in Hyderabad. With trust and honest, we solve the issue as quick as possible.We serve you better compared to others.
    Best waterproofing services in hyderabad
    bathroom leakage services in hyderabad
    roof leakage services in hyderabad
    water tank leakage services in hyderabad
    kitchen leakage services in hyderabad
    Hyderabad waterproofing services

    ReplyDelete
  19. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.
    BCOM 1st, 2nd & Final Year Year TimeTable 2020

    ReplyDelete
  20. Really nice blog, very infromative. You can refer more topics related to SQL like SQL Commands and Advanced SQL from here for future articles
    thanks !

    ReplyDelete
  21. Thanks for the Valuable information.Really useful information. Thank you so much for sharing. It will help everyone.

    Data analytics course in Delhi

    FOR MORE INFO:

    ReplyDelete
  22. This site helps to clear your all query.mgsu ba 1st year result mgsu bsc 3rd year result This is really worth reading. nice informative article.

    ReplyDelete
  23. DevOps is a new trend in software development over the past few years. Although the term is relatively new, it is actually a combination of many practices that have been in use for years. DevOps allows software to be released quickly and efficiently, while still maintaining high levels of security. Azure devops backup

    ReplyDelete
  24. Very useful information.Thankyou so much for this wonderful blog…Great work keep going. Looking for the best database services in Hyderabad hire Cyanous software solutions now.
    Best Database services in Hyderabad
    Best software & web development company in Hyderabad

    ReplyDelete
  25. Nice Post
    https://tajendrasengar.blogspot.com/2011/09/list-of-post-gadget-for-blogger-using.html?showComment=1628682995141#c3300166967764846695

    ReplyDelete
  26. Thanks for sharing such a good information
    Contact us:
    Locksmith Melbourne,
    Melbourne, VIC-3000,
    Australia.
    Phone: 03 9464 1230
    eMail: info@locksmithmelbourne.net
    Web: https://locksmithmelbourne.net/

    ReplyDelete
  27. This is great stuff!! need to share lots of articles for the reader who like your blog and thanks for sharing your ideas and tips
    1Z0-750: Oracle Application Express 18: Developing Web Applications

    ReplyDelete
  28. I am glade that you have shared such a helpful expected article, this will be very important for those who are looking for this type of blog.WEB Designing Services in chandigarh

    ReplyDelete
  29. Very rapidly this web page will be famous amid all blogging and site-building users, due to its pleasant articles or reviews Spot on with this write-up, I truly believe that this site needs a great deal more attention. I’ll probably be back again to read more, thanks for the info!

    BCom 1st Year Admit Card 2022
    BCom 2nd Year Admit Card 2022
    BCom 3rd Year Admit Card 2022

    ReplyDelete

  30. خرید و فروش آهن آلات

    خرید و فروش انواع آهن الات شامل لوله ، نبشی ، ناودانی ، ورق ، پروفیل ، تیر آهن ، استیل ، فولادهای آلیاژی ، میلگردهای صنعتی توسط آهن استقلال

    خرید و فروش آهن آلات

    ReplyDelete