bcquality/microsoft/knowledge/performance/prefer-get-for-primary-key-lookups.md
Jesper Schulz-Wedde 0540c7bf6e Reframe seed-article banners as community contribution invitations
The 35 articles still in their seed form previously carried a banner
reading "Seed article. ... Domain stewards should expand, restructure,
and refine as needed." For a community preview, that phrasing reads as
"TODO left in production" to first-time visitors.

Replace all three banner variants (performance-seeded, security-seeded,
community-ported) with a single positive invitation:

> Contributions welcome — open a PR to refine or extend this article.

Content and structure of the articles are unchanged; only the leading
quote block differs. Articles that had their banner fully stripped in
the earlier triage pass (the showcase-grade ten) are unaffected.
2026-04-23 17:31:36 +02:00

29 lines
964 B
Markdown

---
bc-version: [all]
domain: performance
keywords: [get, findfirst, primary-key, lookup]
technologies: [al]
countries: [w1]
application-area: [all]
---
# Prefer Get for primary-key lookups
> Contributions welcome — open a PR to refine or extend this article.
## Description
Get is a direct primary-key lookup: one index seek, one row, done. FindFirst with SetRange on the primary key fields reaches the same row through a more general code path and carries the overhead of filter setup and a broader optimizer decision.
## Best Practice
When the complete primary key is known, call Get. Use FindFirst only for non-primary-key lookups or when the filter is a partial prefix of the key.
See sample: `prefer-get-for-primary-key-lookups.good.al`.
## Anti Pattern
Setting one SetRange per primary-key field and then calling FindFirst reproduces Get with more typing and slightly worse performance.
See sample: `prefer-get-for-primary-key-lookups.bad.al`.