|
19.05.2023, 12:53 | #1 |
Moderator
|
Цитата:
Сообщение от gl00mie
Казалось бы, что с ним не так? А то, что он не использует параметры и плодит, собака, сотни одинаковых планов запроса, которые вымывают из кэша другие более полезные планы запросов. С помощью "триангуляции" обнаружил, что такие запросы генерятся (в DAX2012 R3) из AccountingEventSourceDocumentProcessor::updateDistributionsForEvent(). Спрашивается, что мешало смастерить там прямой SQL-запрос с параметрами, чтобы он не плодил кучу одинаковых планов запросов?..
|
|
19.05.2023, 13:58 | #2 |
Участник
|
Цитата:
X++: AccountingEventSourceDocumentProcessor::executeSQL(sqlStatementText); Еще и комментарий написан X++: // Do the update as direct SQL as there is a deadlock on AccountingDistribution due to a clustered // index scan operator in the query plan. This operator appears only in low data volume scenarios. // In higher volume scenarios, the plan includes a seek operator using the index I_7452SOURCEDOCUMENTHEADERIDX. // Testing in SSMS indicates an index hint will correct the plan at low volumes and represents minimal // risk at high volumes. In order to enable the index hint on the update_recordset, direct SQL must be used. // Also note that xGlobal::randomPositiveInt32() is the method used by the kernel to populate the // recversion field.
__________________
- Может, я как-то неправильно живу?! - Отчего же? Правильно. Только зря... |
|
19.05.2023, 20:25 | #3 |
Участник
|
Цитата:
X++: private static server boolean updateDistributionsForEvent(recId _accountingEventRecId, AccountingDate _accountingDate, recId _sourceDocumentRecId) { str sqlStatementText; str sqlDate = date2str(_accountingDate, 321, 2, 3, 2, 3, 4, DateFlags::None); // 'YYYY-MM-DD' // Do the update as direct SQL as there is a deadlock on AccountingDistribution due to a clustered // index scan operator in the query plan. This operator appears only in low data volume scenarios. // In higher volume scenarios, the plan includes a seek operator using the index I_7452SOURCEDOCUMENTHEADERIDX. // Testing in SSMS indicates an index hint will correct the plan at low volumes and represents minimal // risk at high volumes. In order to enable the index hint on the update_recordset, direct SQL must be used. // Also note that xGlobal::randomPositiveInt32() is the method used by the kernel to populate the // recversion field. sqlStatementText = strFmt('UPDATE T1 SET ACCOUNTINGEVENT=%1,RECVERSION=%2 FROM ACCOUNTINGDISTRIBUTION T1 WITH (INDEX(I_7452SOURCEDOCUMENTHEADERIDX)) CROSS JOIN SOURCEDOCUMENTLINE T2 ', _accountingEventRecId, xGlobal::randomPositiveInt32()); sqlStatementText += strFmt('WHERE (((T1.PARTITION=%1) AND (T1.ACCOUNTINGEVENT=0) AND (T1.ACCOUNTINGDATE={ d\'%2\'})) AND (T1.SOURCEDOCUMENTHEADER=%3)) AND ', getcurrentpartitionrecid(), sqlDate, _sourceDocumentRecId); sqlStatementText += strFmt('((T2.RECID=T1.SOURCEDOCUMENTLINE) AND (T2.ACCOUNTINGSTATUS=%1 OR T2.ACCOUNTINGSTATUS=%2)) AND (T2.PARTITION=%3)', enum2int(SourceDocumentLineAccountingStatus::Completed), enum2int(SourceDocumentLineAccountingStatus::Canceled), getcurrentpartitionrecid()); return AccountingEventSourceDocumentProcessor::executeSQL(sqlStatementText); } |
|