Sql-server – Ola Hallengren Index maintenance on servers with Availability Groups

availability-groupsindex-tuningola-hallengrensql server

I'm configuring the Ola Hallengren scripts for Index maintenance on all servers in may Availability Group cluster which has several AG's and databases which are not in AG's.

If I select the "ALL_DATABASES" option, is the script intelligent enough to exclude the read only secondary replicas?

Best Answer

Yes, the script is intelligent enough.

This is explicitly stated in the FAQ:

How should I configure IndexOptimize for an Availability Group?

Indexes can only be rebuilt or reorganized and statistics only updated on the primary replica in an availability group. IndexOptimize has a check for this.

The jobs should be configured identically and be enabled and scheduled on all the replicas.