Moment Of Silence
UPDATE: As of 2024-09-19 this has finally been documented.
Automatic tuning is a half-assed feature that has a lot of problems. I wouldn’t trust it any further than I could throw Entity Framework.
Back in October, I opened an issue with Microsoft to document a new-ish stored procedure. It was closed, and to be clear, it was the PM, not the docs team, that refused the request.
Here’s why that’s a bad choice:
- This stored procedure exists and can be executed
- The only documentation for it is going to be this blog post
- Many other configuration procedures that can be misused are documented and regularly executed by end users
For example, sp_configure is well-documented, and there are many changes one could make via those calls to totally hose a SQL Server.
There is documentation available to force and unforce plans in Query Store. There’s also documentation to turn automatic tuning on or off.
If there’s fear that something could be misused, the only cure is to document its proper use and warn of its improper use.
Leaving things up to the imaginations of end-users is quite a mistake.
Valid Use
Just in case Microsoft decides to wipe that issue, here are the parameters currently available for sys.sp_configure_automatic_tuning:
EXECUTE sys.sp_configure_automatic_tuning @option = N'???', @type = N'???', @type_value = ???, @option_value = N'???';
If one wanted to insert valid arguments for those parameter values, one could use these:
EXECUTE sys.sp_configure_automatic_tuning @option = N'FORCE_LAST_GOOD_PLAN', /*Option*/ @type = N'QUERY', /*Target*/ @type_value = 1, /*query_id from Query Store*/ @option_value = N'OFF'; /*Disable*/
What this would effectively do is turn automatic tuning off for a specific query based on its query_id
in Query Store.
If there’s a plan already being forced, you’ll have to unforce the plan too. You can do that with sp_query_store_unforce_plan.
There you have it. Erik Darling cares about you more than Microsoft does.
Thanks for reading!
Going Further
If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 75% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that, and need to solve database performance problems quickly. You can also get a quick, low cost health check with no phone time required.
Will it tune AI to identify frogs, though? The world wants to know.
We pray the frogs are safe from these things.
My question would be, is there a way to turn off automatic tuning for everything AND have Query Store turned off?