There's currently a parameter in IndexOptimize that allows you to thread between databases.
This can be generalized to allow threading even within a database, or even schema.
The only necessary change is to create parameters to indicate the number of total threads allowed, as well as which specific thread this job instance is executing on.
The total number of threads allowed can be used to MODULO the object_ids. Then the specific thread for the job instance will just grab instances where object_id % total_threads = specific_thread - 1.
For example, if you allow 3 total threads, and you're executing thread 1, the job will perform maintenance over objects in which
object_id % 3 = 0 (so any object_id divisible by 3).
This allows users to create an arbitrary number of jobs that can run concurrently.
Concurrency on insert into CommandLog might need to get looked at to avoid deadlocks? Dunno. Just an idea.
There's currently a parameter in IndexOptimize that allows you to thread between databases.
This can be generalized to allow threading even within a database, or even schema.
The only necessary change is to create parameters to indicate the number of total threads allowed, as well as which specific thread this job instance is executing on.
The total number of threads allowed can be used to MODULO the object_ids. Then the specific thread for the job instance will just grab instances where object_id % total_threads = specific_thread - 1.
For example, if you allow 3 total threads, and you're executing thread 1, the job will perform maintenance over objects in which
object_id % 3 = 0 (so any object_id divisible by 3).
This allows users to create an arbitrary number of jobs that can run concurrently.
Concurrency on insert into CommandLog might need to get looked at to avoid deadlocks? Dunno. Just an idea.