Skip to content

Speed up active IP collector query#3793

Merged
lunkwill42 merged 1 commit into5.17.xfrom
speedup/fix-comparison-operator-in-ip-addr-collector
Feb 19, 2026
Merged

Speed up active IP collector query#3793
lunkwill42 merged 1 commit into5.17.xfrom
speedup/fix-comparison-operator-in-ip-addr-collector

Conversation

@lunkwill42
Copy link
Copy Markdown
Member

Scope and purpose

Use arp.end_time >= 'infinity' instead of = 'infinity' in the static active IP collection query (get_static_query() in activeipcollector/collector.py), which runs every 30 minutes via cron.

The semantics are identical since nothing is greater than infinity. This change can significantly improve query performance on installations where partial indexes have been defined with a >= 'infinity' clause, as PostgreSQL can then use the partial index directly instead of combining it with a full index scan via BitmapAnd.

Tested on a production database: query time dropped from ~50s to ~5s with a suitable partial index in place.

Contributor Checklist

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

Use arp.end_time >= 'infinity' instead of = 'infinity' in the static
active IP collection query, which runs every 30 minutes. The semantics
are identical since nothing is greater than infinity.

This change can significantly improve query performance on installations
where partial indexes have been defined with a >= 'infinity' clause, as
PostgreSQL can then use the partial index directly instead of combining
it with a full index scan via BitmapAnd.
@lunkwill42 lunkwill42 self-assigned this Feb 17, 2026
@sonarqubecloud
Copy link
Copy Markdown

@lunkwill42 lunkwill42 requested a review from a team February 17, 2026 14:08
@lunkwill42 lunkwill42 marked this pull request as ready for review February 17, 2026 14:08
@github-actions
Copy link
Copy Markdown

Test results

    20 files      20 suites   25m 1s ⏱️
 2 864 tests  2 864 ✅ 0 💤 0 ❌
16 356 runs  16 356 ✅ 0 💤 0 ❌

Results for commit 6562f77.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.36%. Comparing base (e90b3a1) to head (6562f77).
⚠️ Report is 6 commits behind head on 5.17.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           5.17.x    #3793      +/-   ##
==========================================
+ Coverage   63.33%   63.36%   +0.02%     
==========================================
  Files         619      619              
  Lines       45875    45875              
  Branches       43       43              
==========================================
+ Hits        29057    29070      +13     
+ Misses      16808    16795      -13     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lunkwill42 lunkwill42 merged commit 2f1c7b5 into 5.17.x Feb 19, 2026
19 checks passed
@lunkwill42 lunkwill42 deleted the speedup/fix-comparison-operator-in-ip-addr-collector branch February 19, 2026 11:53
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.

2 participants