Skip to content

perf: use indexed LoadPolicy in UpsertPolicy instead of full scan - #294

Merged
v0lkan merged 1 commit into
mainfrom
fix/upsert-policy-indexed-lookup
Jul 15, 2026
Merged

perf: use indexed LoadPolicy in UpsertPolicy instead of full scan#294
v0lkan merged 1 commit into
mainfrom
fix/upsert-policy-indexed-lookup

Conversation

@v0lkan

@v0lkan v0lkan commented Jul 14, 2026

Copy link
Copy Markdown
Member

UpsertPolicy called LoadAllPolicies and looped to find one policy by name, loading and decrypting every policy on every upsert. Switch to the existing LoadPolicy(ctx, name) indexed lookup (name is the primary key), treating ErrEntityNotFound as the create case. Behavior is unchanged; cost drops from O(n) with full decryption to a single indexed read.

Also fix stale "by its ID" doc comments and id parameter names on the LoadPolicy and DeletePolicy backend interface methods (policies are keyed by name).

Context housekeeping in .context/TASKS.md: mark the lookup task done; skip the obsolete maxShardID task (the constant no longer exists); and retarget the DB-operation-timeout task at the SDK's env.DatabaseOperationTimeoutVal(), where that accessor now lives.

Spec: TBD

…scan

UpsertPolicy called LoadAllPolicies and looped to find one policy by
name, loading and decrypting every policy on every upsert. Switch to the
existing LoadPolicy(ctx, name) indexed lookup (name is the primary key),
treating ErrEntityNotFound as the create case. Behavior is unchanged;
cost drops from O(n) with full decryption to a single indexed read.

Also fix stale "by its ID" doc comments and id parameter names on the
LoadPolicy and DeletePolicy backend interface methods (policies are keyed
by name).

Context housekeeping in .context/TASKS.md: mark the lookup task done;
skip the obsolete maxShardID task (the constant no longer exists); and
retarget the DB-operation-timeout task at the SDK's
env.DatabaseOperationTimeoutVal(), where that accessor now lives.

Spec: TBD
Signed-off-by: Volkan Özçelik <volkan.ozcelik@broadcom.com>
@v0lkan v0lkan self-assigned this Jul 14, 2026
@v0lkan
v0lkan merged commit b150953 into main Jul 15, 2026
14 checks passed
@v0lkan
v0lkan deleted the fix/upsert-policy-indexed-lookup branch July 15, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant