olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.91k stars 756 forks source link

Polybase Stats Rebuild Fix #645

Open heaivilinn opened 2 years ago

heaivilinn commented 2 years ago

Per Microsoft, statistics for external tables cannot be ALTERED. If a rebuild is required, they must be dropped and re-created. As such, I've updated the code to correctly identify external tables and drop/add stats on them by default. A parameter was added that if change to anything other than REBUILD, will ignore stats maintenance work on external tables.

heaivilinn commented 1 year ago

@olahallengren, is there something specific I need to do to get this PR approved and merged into the core source control? Or is it just a matter of time and resources? Appreciate the update.

steverezhener commented 1 year ago

@heaivilinn , great job on that index optimize code for polybase table stats. A few things missing:

  1. Need to add WITH FULLSCAN or WITH SAMPLE [0-9][0-9] PERCENT after the parenthesis line #2279. unless indexoptimize is used strictly for polybase objects with @StatisticsSample='FULL' or similar
  2. script could create stats if missing (more like an enhancement)
heaivilin commented 10 months ago

@steverezhener, apologies for the very long wait on a response here. Somehow got unsubscribed and then I got pulled away on other things.

Regarding No.1, wouldn't this be handled by the @CurrentUpdateStatisticsWithClauseArguments variable that is added to @CurrentCommand on line 2347? Code seems to show it, but I'm having to rebuild my test environment as I've switched jobs and the new one doesn't use Polybase at present.

Regarding No.2, potentially, but would you want it to do this? I'd be interested in what the community thinks. Maybe something that is done, but not turned on by default as I know I wouldn't want it done by default without my knowledge.