Skip to content

Reduce database work when creating lists and saving domains - #8379

Draft
labkey-jeckels wants to merge 5 commits into
developfrom
fb_list_create_metadata_load
Draft

labkey-jeckels wants to merge 5 commits into
developfrom
fb_list_create_metadata_load

Conversation

@labkey-jeckels

@labkey-jeckels labkey-jeckels commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Creating a list or picklist through property-createDomain.api costs far more database work than it should. A customer load test of picklist creation showed that each create reloaded unrelated caches and took dozens of pooled connections. This PR cuts that work: in local testing, 50 picklist creates went from 164 to 109 statements per create, from 37 to 24 pooled connection borrows per create, and from 0.254 s to 0.205 s median latency.

Changes

  • Domain saves invalidate only the caches for the saved domain and its changed properties, instead of clearing property-value and experiment caches globally
  • Cached values that hold a Domain or DomainProperty are flagged unless their cache is evicted when the domain is saved; the specimen domain creation cache now holds domain ids instead
  • Creating a list no longer indexes it twice
  • Cache reloads after commit share one pooled connection instead of borrowing one per statement
  • Domain saves keep stored default values they didn't load, can still clear a default explicitly, and skip default-value writes that change nothing
  • Tests for cache invalidation scope, default-value preservation and clearing, and connection sharing for cache reloads

Tasks

  • Claude Code Review
  • Manual Testing
  • Test Automation

Domain saves now invalidate only the caches they affect, list creation skips a duplicate index pass, and post-commit tasks share one pooled connection. Also stops domain saves from dropping stored default values.
Hold the thread connection only for cache replay and domain audit writes, so other post-commit tasks can open transactions without holding a second connection. Domain saves can clear stored defaults again and skip default writes that change nothing; the specimen domain creation cache holds domain ids instead of Domains.
@labkey-jeckels

Copy link
Copy Markdown
Contributor Author

Updated local benchmark after 494b962, which narrows the post-commit connection hold to cache replay and domain audit writes and skips no-op default-value writes. Each run is 50 picklist creates through property-createDomain.api after 20 warmup creates. Numbers are per create.

develop this branch
SQL statements 164 109
Pooled connection borrows 37.1 24.2
BEGIN 25.0 14.6
Median latency 0.254 s 0.205 s

Borrows are about 3 per create higher than with the earlier hold across every post-commit task. That is the cost of not holding a pooled connection while post-commit tasks may open their own transactions.

@labkey-jeckels labkey-jeckels self-assigned this Nov 24, 2026
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