2012 R3. Внесены все изменения по мьютексам в BatchRun и даже больше (ускоряющие хинты), но неожиданно всплыла очень медленная вставка в таблицу BatchConstraintsHistory. Из-за этого другие пакетники нарываются на блокировку мьютекса и ничего не стартует и не двигается десятками минут. Переиндексации и обновление статистик тут особо не работают, так как таблички часто меняются, а структура запроса не позволяла применить стандартные мантры хинтов из 2012 (
forceSelectOrder forceNestedLoop). Но удалось переписать и этот запрос. Может кому-то пригодится.
BatchRun.serverProcessFinishedJobs
Оригинальный код:
X++:
insert_recordset batchConstraintsHistory
(BatchId, ExpectedStatus, DependsOnBatchId)
select RecId from batchHistory
join ExpectedStatus from batchConstraints
where batchHistory.BatchId == batchConstraints.BatchId
join RecId from batchHistoryDepends
where batchHistoryDepends.BatchId == batchConstraints.DependsOnBatchId
exists join batchJobHistory
where batchJobHistory.Finishing == 1 && batchJobHistory.RecId == batchHistory.BatchJobHistoryId
&& batchJobHistory.RecId == batchHistoryDepends.BatchJobHistoryId;
Заменил на:
X++:
insert_recordset batchConstraintsHistory
(DependsOnBatchId, ExpectedStatus, BatchId)
select forcePlaceholders forceSelectOrder forceNestedLoop batchJobHistory
where batchJobHistory.Finishing == 1
join RecId
from batchHistoryDepends
where batchHistoryDepends.BatchJobHistoryId == batchJobHistory.RecId
join ExpectedStatus
from batchConstraints
where batchConstraints.DependsOnBatchId == batchHistoryDepends.BatchId
join RecId
from batchHistory
where batchHistory.BatchJobHistoryId == batchJobHistory.RecId
&& batchHistory.BatchId == batchConstraints.BatchId;