Skip to content

Batch animal status lookups; don't re-run them on every weight keystroke - #1033

Closed
labkey-jeckels wants to merge 1 commit into
release26.7-SNAPSHOTfrom
26.7_fb_weightEntryOptimization
Closed

Batch animal status lookups; don't re-run them on every weight keystroke#1033
labkey-jeckels wants to merge 1 commit into
release26.7-SNAPSHOTfrom
26.7_fb_weightEntryOptimization

Conversation

@labkey-jeckels

Copy link
Copy Markdown
Contributor

Rationale

Removes a client-side request fan-out that made the weight and feeding forms issue one database query per animal. On 2026-09-10 a single weight-form session on one room sustained 300-380 requests per minute for roughly thirteen minutes, raising p95 response time for every other user on the server from 456 ms to 1.29s.

The weight form was the worse of the two because its status check re-ran the whole fan-out on every field edit, not just once per form; its slowest requests took up to 114 seconds and returned normally, so browsers gave up long before the server did and users reported timeouts that left no server-side errors to find.

The per-row lookups that populate each form's animal info pane are unchanged, since they fetch one animal at a time and feed a display that genuinely uses those columns.

Changes

  • Look up animal statuses for an entire form in one query rather than one query per animal, and request only the two columns the check needs instead of the full demographics row and all of its lookups.
  • Re-run the weight form's status check only when the set of animals changes, rather than on every field edit.
  • Preserve each form's existing save rule: the weight form still requires every animal to be alive, and the feeding form still blocks only on dead animals.
  • Distinguish a genuine request failure from an animal that has no demographics record; the previous error path could itself throw while handling a failure.

@labkey-jeckels

Copy link
Copy Markdown
Contributor Author

@guyinco6nito As I noted in the related ticket, I'm not set up to test this locally. Please work with your team to adopt this or a similar kind of patch ASAP.

LeviCameron1 added a commit that referenced this pull request Sep 10, 2026
## Rationale
Based off of Josh's PR for 26.7 this extends it a little bit more adding
a timeout on requests to 500ms. It looks like the ID field was a big
problem since it was making a call to the demographics to verify the ID
was correct for each keystroke. This further optimization waits for the
user to stop typing before making that call.

The feeding form doesn't seem to have the same problem with the ID field
as the weights form so I didn't make any changes to it.

## Related Pull Requests
#1033

## Changes

- Added timeout for call to demographics table to ensure the user stoped
typing before calling. Weights form only.

---------

Co-authored-by: labkey-jeckels <jeckels@labkey.com>
@labkey-jeckels

Copy link
Copy Markdown
Contributor Author

Closing in favor of Levi's 26.3 PR.

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