Partial records cause JIT load on full-field operations
When SetLoadFields, AddLoadFields, or SetBaseLoadFields is used on a record variable that subsequently performs Insert, Delete, Rename, TransferFields or Copy, the platform must JIT-load all remaining fields before the operation can execute.
This causes two problems:
- Performance penalty: The JIT load triggers an extra SQL roundtrip, making the code strictly slower than not using partial records at all (2 roundtrips instead of 1).
- Runtime errors: Under concurrent access, the JIT load can fail with “Inconsistent read of field(s)” (when another user modifies the record between the initial load and the JIT load) or “JIT loading of field(s) failed” (when the record is deleted or renamed).
Example
procedure DeleteItem(ItemNo: Code[20])
var
Item: Record Item;
begin
Item.SetLoadFields(Item."No."); // Partial records cause JIT load on full-field operations [PC0031]
Item.Get(ItemNo);
Item.Delete();
end;Remove the SetLoadFields call — since the record will be deleted, loading all fields upfront is correct:
procedure DeleteItem(ItemNo: Code[20])
var
Item: Record Item;
begin
Item.Get(ItemNo);
Item.Delete();
end;Exception
The diagnostic is not raised for Modify, ModifyAll, DeleteAll, or Init. Modify only writes changed fields and does not trigger a JIT load. ModifyAll and DeleteAll are set-based operations and Init is an initialization operation — none of these require all fields to be loaded.
The diagnostic is also suppressed when the write operation is inside a conditional branch (if, case, while, for, foreach), because the write may only execute on a path where the record was not loaded via partial records. repeat..until loops are still flagged because the body always executes at least once.
Temporary record variables (no SQL backing, no JIT load) and record variables where Clear() or Reset() is called between the SetLoadFields and the write operation (resetting the partial records state) are also skipped.
See also
- PC0030: Use SetLoadFields before read operations
- Using Partial Records on Microsoft Learn
- Partial Records FAQ on Microsoft Learn
- SetLoadFields Performances by Stefano Demiliani