bcquality/microsoft/knowledge/performance/use-findset-readonly-by-default.md
Jesper Schulz-Wedde 23184480d0 Triage seed knowledge and document admission test for preview
Remove seven knowledge files whose content is generic software-engineering
guidance that a capable LLM already applies without BCQuality present
(HTTPS-only, secret-leakage-in-errors, no-credentials-in-URLs, silent
security-error swallowing, short transaction scope, HTTP timeouts,
StrSubstNo-vs-concatenation). These fail the remedial-knowledge premise
and dilute the signal of the preview corpus.

Strip the "Seed article — domain stewards should expand" banner from ten
files that are ready to showcase (AA0232/AA0233 rules, FindSet read-only
semantics, SetLoadFields ordering and usage, CalcFields-in-loops,
SecretText end-to-end, DataClassification). The banner remains on files
that still need domain-steward refinement.

Add a "What belongs here" section to the README stating the admission
test: a file exists only if a modern LLM would get something wrong or
miss something without it. Gives contributors a concrete yes/no filter
before they open a PR.
2026-04-23 15:47:01 +02:00

1.2 KiB

bc-version domain keywords technologies countries application-area
26..28
performance
findset
lock
locktable
readonly
update
al
w1
all

Use FindSet in read-only mode by default

Description

FindSet has two modes: FindSet() and FindSet(false) are read-only and take no write lock; FindSet(true) calls LockTable before fetching. Write locks are expensive and hold for the remainder of the transaction, so passing true when you do not intend to modify the records increases contention under load.

Best Practice

Call FindSet with no arguments when the loop only reads field values. Pass true only when the same loop is expected to call Modify, Delete, or Rename on the record, and the correctness of the operation depends on the table being locked for the full iteration.

See sample: use-findset-readonly-by-default.good.al.

Anti Pattern

Writing FindSet(true) reflexively for every iteration forces the platform to take a LockTable on every call, even when the loop only reads values. The older two-parameter signature FindSet(ForUpdate, UpdateKey) is obsolete and must not be used.

See sample: use-findset-readonly-by-default.bad.al.