Statistics aren't being updated if they belong to an index that wasn't updated. In the section with the comment Remove statistics if it is handled by index rebuild / reorganize the script removes stats that exist in #idxBefore but that includes all indexes, not just the ones that are being rebuilt. It should probably include the same where clause and/or delete records from #idxBefore that aren't being updated.
This was the change we made locally to fix the issue:
Statistics aren't being updated if they belong to an index that wasn't updated. In the section with the comment
Remove statistics if it is handled by index rebuild / reorganize
the script removes stats that exist in#idxBefore
but that includes all indexes, not just the ones that are being rebuilt. It should probably include the same where clause and/or delete records from#idxBefore
that aren't being updated.This was the change we made locally to fix the issue: