bcquality/microsoft/knowledge/performance/preserve-buffered-inserts-by-separating-target-reads.bad.al
Jesper Schulz-Wedde 87ba36e650
Add BC performance knowledge from OptimAL learnings (#198)
* Add BC performance knowledge from OptimAL learnings

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Address review feedback on performance guidance

Clarify predicate-supporting keys versus covering queries, demonstrate proven cache reuse, and evaluate the updated partial-load and bulk-update rules.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-29 17:21:28 +02:00

61 lines
1.5 KiB
AL

// Each invocation exclusively owns a new run; these tables have no write logic.
table 50364 "Perf Input"
{
DataClassification = CustomerContent;
fields
{
field(1; "Row No."; Integer) { }
field(2; "Item No."; Code[20]) { }
field(3; Quantity; Decimal) { }
}
keys
{
key(PK; "Row No.") { Clustered = true; }
}
}
table 50365 "Perf Output"
{
DataClassification = CustomerContent;
fields
{
field(1; "Run ID"; Guid) { }
field(2; "Line No."; Integer) { }
field(3; "Item No."; Code[20]) { }
field(4; Quantity; Decimal) { }
}
keys
{
key(PK; "Run ID", "Line No.") { Clustered = true; }
}
}
codeunit 50366 "Perf Buffered Insert Bad"
{
procedure CopyRun(var TempInput: Record "Perf Input" temporary) RunId: Guid
var
Output: Record "Perf Output";
NextLineNo: Integer;
begin
RunId := CreateGuid();
Output.SetRange("Run ID", RunId);
if TempInput.FindSet() then
repeat
if Output.FindLast() then
NextLineNo := Output."Line No." + 1
else
NextLineNo := 1;
Output.Init();
Output."Run ID" := RunId;
Output."Line No." := NextLineNo;
Output."Item No." := TempInput."Item No.";
Output.Insert(false);
Output.Quantity := TempInput.Quantity;
Output.Modify(false);
until TempInput.Next() = 0;
end;
}