Measure and drop redundant AuditLogEntries single-column indexes #70
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Register row 135 (deferred-work register).
ReviewRemediationIndexesadded compositeAuditLogEntriesindexes(EntityType, Timestamp DESC),(User, Timestamp DESC),(Timestamp DESC, Id DESC); the older single-column timestamp/user/entity-type indexes may be dead weight on a write-heavy table.Revisit trigger (from register): Measure
sys.dm_db_index_usage_statsafter a few weeks in QA, then drop unused ones via a migration.Current state: The migration was applied on DEV vd03 and QA vq03/vq04 on 2026-10-22 (migrations 57 → 58;
docs/deployment/deployment-records/2026-10-22-*.md), so the measurement clock started then. Index usage can be read with a direct SQL login (no remote exec needed).Source:
docs/plans/2026-07-08-deferred-work-register.mdrow 135Tried to take the measurement on 2026-11-09 (18 days after the 2026-10-22 migration) with a direct, read-only SQL query. Blocked on access: the only SQL login available from the Mac (the Historian
wonderapp-style login) cannot open theScadaBridgedatabase on eitherwonder-app-vd03(DEV) orwonder-sql-vq03(QA) — "Cannot open database ScadaBridge requested by the login". I did not pull the app's own connection string off the boxes.To unblock: either grant a read-only login
VIEW DATABASE STATE+CONNECTonScadaBridge(QA first), or run this as the DBA and paste the output here:Decision rule once the numbers are in: a single-column index with 0 seeks/scans/lookups since the last restart and a restart older than ~2 weeks, whose leading column is covered by one of the
ReviewRemediationIndexescomposites, gets dropped in a migration (QA first). Addingblockedlabel.Measured 2026-11-13: no migration yet. The window is too short, and no index was read on either tier.
Read-only DMV query over a direct SQL login (
sys.dm_db_index_usage_stats+sys.dm_db_index_operational_stats).sqlserver_start_timeEach single-column index is 72 KB. Each composite is 200 KB.
Decision. Both windows are under two weeks, because SQL restarts after the 2026-10-22 migration reset the counters. Every index reads zero, including the composites, so a zero on the old indexes proves nothing. In code, the three are left prefixes of the composites, and the
CentralUiRepositoryfilters/order and theConfigAuditPurgeServicerange are all covered. So a drop is sound in principle, but it has not been measured yet. Write cost is negligible (~500 rows, ~1 insert/day on QA), so waiting costs nothing.Re-measure on or after 2026-11-27. Check
sqlserver_start_timefirst. If the composites show reads and the single-column indexes still show zero, dropTimestamp/User/EntityType(Down() recreates them). If everything is still zero, the owner decides: drop on static grounds, or exercise the config-audit page on QA first.Evidence:
docs/plans/2026-11-13-auditlogentries-index-usage.md(mainbba3c348). The issue stays open andblockedon the re-measure.Reminder set: re-measure on 2026-11-27 (issue due date). Steps: (1) check
sqlserver_start_timeon vd03 and wonder-sql-vq03 — a restart since the last read resets the window; (2) re-run the DMV query from the 2026-11-09 comment; (3) apply the decision rule from the 2026-11-13 comment (composites read and single-column still zero → dropTimestamp/User/EntityType, QA first; all zero → owner decides).Re-measured 2026-12-02 on QA. No migration: the drop rule is not met, and the result points the other way.
Read-only query of
sys.dm_db_index_usage_statsover a direct SQL login onwonder-sql-vq03/ScadaBridge. No WinRM.sqlserver_start_timeis 2026-11-03 07:09, so the window is ~29 days, past the two-week minimum.20261115221558_RemoveAuditLogHashChain.Every index shows 160 updates (150 for EntityName).
¹ The DMV shows 3 scans. The third is the measurement query itself (
COUNT/MAX(Timestamp)at 13:23:10), so it is left out. The DMV keeps only the latest scan time, so the date of the earlier scans is unknown.Reading. The config-audit page was used during the window (filtered reads on 2026-11-20). When it was, the optimizer read the old single-column
EntityTypeandTimestampindexes, and none of the three composites was read. The rule from 2026-11-13 says to drop only if the composites show reads and the single-column indexes show none. QA shows the reverse, so the rule is not met.Dropping them would still be safe in function, because each single-column index is a left prefix of a composite. But the measurement doesn't back it, and it would save only about 216 KB and 3 index writes per audit row. At 730 rows these plan choices say little about how a large table would behave.
Recommendation: close as won't-fix. The single-column indexes are in use and cost almost nothing. Owner to decide. DEV vd03 was not re-measured.