Rails 6 had added the :destroy_async option to delete the associated records in a background job whenever the foreign_key constraint would be disabled.

But what if the associated records are too large? In this case, by default, the single background job will delete all of them and that can be time-consuming. To handle this, and make it fast, Rails now allows adding the active record configuration to specify the maximum number of records that will be destroyed in a single background job and enqueue additional jobs when the number of records exceeds that limit.

Example:

Suppose we have a Product model and a Review model.

Notice that we have added the :destroy_async option to delete review records in a background job.

### Before

As it can be seen all the reviews get deleted in a single async job with ID 880513a7-f6c4-4a35-8d33-6d69a737031e.

### After

Now, we can add the configuration to specify the maximum number of records that will be destroyed in a single background job.

Now, if we try to delete a Product with 50 reviews, Rails will enqueue 5 DestroyAssociationAsyncJobs to delete all of them.

Note: The enhancement is yet to be released in the official Rails version

Check out the PR for more details.