Repository navigation
fix(browse): brief site list to avoid count-annotation timeout (0.8.1) - #63
Merged
Merged
Conversation
…n timeout NetBox's full site list serializer attaches per-site aggregate counts (device/prefix/rack/vlan/circuit), each a subquery over a large table. On a sizable instance that's slow enough to exceed the request timeout — observed on a real instance: GET /api/dcim/sites/?limit=100 took >120s, while the nav count (limit=1) and every other browse kind returned in <1s. The full list was effectively unusable. The site browse only renders name + slug, both present in NetBox's `brief` representation, which omits the counts. Request brief=true for the site browse: ~400x faster in testing (0.3s vs >120s), with no column loss. Opening a site still fetches the full object for its detail view. Site is the only browse kind heavy enough to need this; the rest list fine at full and keep their columns. Bump 0.8.0 -> 0.8.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Browsing sites in the TUI times out on a real instance:
…while the nav count for sites shows up fine. That split is the tell.
Root cause
NetBox's full site list serializer attaches per-site aggregate counts (
device_count,prefix_count,rack_count,vlan_count,circuit_count, …), each a subquery over a large table. The count query (limit=1) is cheap, but serializing a full page of sites runs those subqueries per row. Measured against a live 149-site instance:?limit=1(nav count)?limit=100(full list)?limit=100&brief=trueRaising
timeout_secsdoesn't help (it's >2 minutes). Every other browse kind (devices, racks, prefixes, IPs, vlans, vrfs, route-targets) lists in 0.2–0.8s at full — sites is the only heavy one.Fix
Request NetBox's
briefrepresentation for the site browse only. Brief omits the counts and returnsid/url/name/slug— and the site browse index only rendersname+slug, so there's no column loss. Opening a site still fetches the full object for its detail view. Other kinds are untouched (they're already fast and keep their full columns).~400× faster (0.3s vs >120s) on the affected instance.
Verification
site_browse_requests_brief_to_skip_count_annotations(wiremock matches only whenbrief=trueis sent).id/url/name/slug, so they deserialize cleanly.Bumps 0.8.0 → 0.8.1.