Does Automatic tuning in Azure SQL Database reorganize and rebuild indexes? - database

We are looking into turing on Automatic tuning in Azure SQL Database (https://learn.microsoft.com/en-gb/azure/azure-sql/database/automatic-tuning-overview?view=azuresql) and use all 3 available options. Does the create index option reorganise or rebuild the index from time to time? I can't find any documentation on how the index that is created is maintained. Can someone please point me to such documentation?

Automatic Tuning on Azure SQL Database does not do maintenance of indexes and statistics. Here a Microsoft Engineer states that in most scenarios is not needed, but in the same forum thread I shared my experience step-by-step with images on how you can schedule a database maintenance on Azure SQL.

Related

Azure SQL Database Column Statistics

I am having trouble finding documentation regarding column statistics on a Microsoft Azure SQL Server database. I noticed recently that query plans had warnings in SSMS due to missing column statistics. Further investigation revealed that 'Auto Create Statistics' and 'Auto Update Statistics' were turned off for our database.
I understand that with our local SQL databases statistics are important to performance in that they let the query analyzer make educated guesses about the cardinality of results. Are statistics still important in an Azure SQL database? Is there any documentation about best practices here? Are there cases where automatic statistics should be turned off?
There is no difference between statistics in SQL Server and Azure SQL Database. Azure SQL Database is just a manged, and automatically-updated flavor of SQL Server. Here's the doc page: Statistics
Are there cases where automatic statistics should be turned off?
Rare cases. The vast majority of SQL Server databases rely on automatic creation and updates of statistic, perhaps augmented by scheduled index maintence.
Automatic statistics are created when needed, and will be created before the query that needs them can be optimized. Sometimes this can cause an unacceptable delay, so you would set them to create asynchronously, and let the query proceed without them, or rely on a manual process review and create needed indexes and statistics.

How to measure the performance of the Azure SQL DB?

I need to measure the SQL Azure DB performance using DTA, is it possible or not, if not what is the workaround to consume a workload file (.trc)??
Database Engine Tuning Advisor does not support Azure SQL Database. It is also not possible to create a trace file from an Azure SQL Database using SQL Server Profiler.
SQL Azure automates the creation of indexes that may improve performance of your workload with a feature named automatic tuning. Automatic Tuning on Azure SQL also drops redundant indexes and uses the best execution plan for queries
Alberto is correct - there are features within SQL Azure which help watch and improve the performance of your database queries automatically in some cases. Profiler trace + DTA are not currently supported in SQL Azure. The DTA (Database Tuning Advisor) feature in SQL Server is very good for taking traces and trying to replay them on a different server to simulate possible index and partitioning changes which could improve your performance. The automatic tuning feature does that for you without having to use DTA today yourself.
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-automatic-tuning
If all you want to do is explore the performance of your database, then you can use the query store in SQL Azure (and SQL Server 2016+) to do this kind of analysis.
https://azure.microsoft.com/en-us/blog/query-store-a-flight-data-recorder-for-your-database/
https://learn.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store?view=sql-server-2017
If you have not tried this using a recent release of SQL Server Management Studio(SSMS), then I highly suggest you download this and try it. You can see top N queries by different metrics, plan changes over time, and other metrics which give you faster insight into the performance profile of your database + application.
There is no way to take a .trc file today and examine it in the query store, but you can enable query store in an on-premises SQL Server (2016+) and then record your production workload for awhile to see how it is behaving. Please understand there is an overhead to running with the query store on - usually it is modest, but for highly ad hoc OLTP query workloads you may see larger overhead. There are some knobs to tune this, so please just go through normal due diligence before modifying a production system. If you have problems, turn it back off and re-examine until you have the right settings to help capture the relevant data from your workload to help make tuning decisions.
Hope that helps!
Sincerely,
Conor Cunningham
Architect, SQL

Automatic database indexing

I have a database which is used by a multi-tenant application. In this database workloads are dynamic and change continuously. Therefore I have to allocate a DA to continuously manage the database. But I thought to use an automated service for this task such as Azure SQL Database Advisor - Automatic index management (platform is not important - I am OK with using MS sql server or oracle or other RDBMS).
I want to know how these automated indexes are actually working.Can I replace database administrator with these automatic indexers. I read that whenever a query execution plan is generated it will find out all the useful indexes to execute that query. Then it uses the indexes which really exist and cache some data about indexes which don't exist. If an index data is cached again and again the sql adviser will show that as a recommended index. But I want to know can we relay on this, what about update and insert queries? If I have a table where records are frequently updated, these automated indexing systems will consider that?
Note that Index Advisor is only available in SQL Database (Azure).
In the background Index Advisor is a machine learning algorithm, a relatively simple and quite effective one. It will analyze your workload, see if you would benefit from indexes. If he thinks you would it will show you as a recommendation - if you turn automatic index creation/dropping on it will actually create the index. To understand better how it works take a look at Channel 9. Note that before you apply a recommendation you can have an estimated impact.
Now the algorithm can make mistakes, right? So once the recommendation is applied it can automatically be reverted based on its performance.
Also note that next to Index Advisor you can check the Query Performance Insights that will show the performance of you queries. So this can help your DBA diagnose other, non-index related problems.
But note that Index Advisor will not drop and create for you new indexes every hour, it takes for him a day or two. So if your database's workload is changing very fast then I am not sure any automatic management tool or DBA will react quickly enough for your workload.

Safest way to apply changes recommended by sql query on CRM Dynamics

I am new to CRM, trying to help our CRM team to make our CRM application faster. We have on-premises 2015 version.
I ran the stats query on CRM DB, there are more than 1000 indexes having more 30% avg_fragmentation.
what is safest way to resolve this issue? can we do this in Live CRM DB or can we create a copy of Live CRM DB and do on the live again? and another question is how to create live copy and manage in such way so that whenever main DB is down it goes to live copy and keep application running?
PLEASE Help.
Creating and de-fragmenting indexes on the CRM database are supported operations. Microsoft recommends that indexes with a fragmentation level greater than 30% be rebuilt, while those with greater than 10% fragmentation should be reorganized.
Defragmenting your production indexes is perfectly safe but you should run the operation overnight to minimize any affect on system performance.

Azure Database Query Optimizer using View Indices

SQL Server Enterprise Edition's query optimizer will use indices from a view to increase performance of a query even if the view is not explicitly referenced in the query, if applicable. Question: does Azure Database do the same thing? I know SQL Server Express does not do this, for example. I want to ensure I can still get the performance I need from the query optimizer when doing a sort on a joined table with a few million users (works great on enterprise edition but takes several seconds on express - bottle neck at the sort).
Sometime last year (2012) Microsoft announced that the engine was the same between SQL Server and SQL Azure (now called Windows Azure SQL Database :/). So you will likely get the same behavior. Same performance may be another question. Windows Azure SQL Database is also keeping replicas in place in the event of hardware failure. You get the benefit of the secondary coming online in a fashion that is seamless to you. But, This does have a bit of a performance cost. Also, the SQL running in Windows Azure is running in a shared environment. It is pretty well documented that the performance is not the same as a local dedicated multi-processor machine with fast storage. It is a bit of an unfair comparison multi-user, multi-instance vs. dedicated. For many applications this is fast enough, but not all.

Resources