Repository navigation
events, tasks: speed up the event and task queries - #27692
Merged
Merged
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Contributor
Playwright e2eDownload this run's HTML report and traces, then open the report: gh run download 44206165290 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-reportInstallation instructionsInstructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-8890250c44c2b6457f1a9f058f4bd1033ba4bbc8
# Distroless image: AUTHENTIK_TAG=gh-8890250c44c2b6457f1a9f058f4bd1033ba4bbc8-distroless
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-8890250c44c2b6457f1a9f058f4bd1033ba4bbc8
# Distroless image: tag: gh-8890250c44c2b6457f1a9f058f4bd1033ba4bbc8-distrolessAfterwards, run the upgrade commands from the latest release notes. |
The system tasks page counted tasks by status through the status index, which reads every matching task from the table. Once other queries push the tasks out of the cache, that was slower than main's sequential scan. A partial index on mtime that includes the status answers the count without the table and lists the page newest first.
Member
Author
jsachs
requested changes
Nov 16, 2026
jsachs
approved these changes
Nov 18, 2026
dominic-r
enabled auto-merge (squash)
November 18, 2026 14:26
dewi-tik
approved these changes
Nov 18, 2026
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 19, 2026
* main: core: allow launch URLs relative to the current host (#27632) website/releases: 2026.11: benchmaxxing (#27796) core: bump goauthentik/fips-python from `72f6e14` to `8fd04de` in /lifecycle/container (#27920) root: require Node.js 24.22.3 (#27906) admin/files, core: read the cached icon URLs of a list in one query (#27695) core: bump pnpm to 12.22.0 everywhere (#27905) web/elements: fix the wizard next button staying disabled (#27660) events, tasks: speed up the event and task queries (#27692) core: bump the pnpm group across 2 directories with 1 update (#26843) core: bump astral-sh/uv from 0.13.8 to 0.13.9 in /lifecycle/container (#27893) core: bump aws-cdk-lib from 2.275.0 to 2.276.0 (#27899) core: bump jsonpatch from 1.44 to 1.46 (#27898) core: bump cachetools from 7.3.1 to 7.3.2 (#27897) core: bump google-api-python-client from 2.201.0 to 2.202.0 (#27896) core: bump goauthentik/fips-python from `96730cd` to `72f6e14` in /lifecycle/container (#27894) ci: bump taiki-e/install-action from 2.90.3 to 2.90.4 in /.github/actions/setup (#27895) core: bump goauthentik/fips-debian from `56dbb46` to `712d5d1` in /lifecycle/container (#27892) core: bump github.com/grafana/pyroscope-go from 1.4.3 to 1.5.0 (#27891) providers/saml: add option to ignore ForceAuthn from the SP (#27057) website/integrations: add Radarr (#27882)
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 19, 2026
…enance-2 * web/spike/icon-identification: (21 commits) core: allow launch URLs relative to the current host (#27632) website/releases: 2026.11: benchmaxxing (#27796) core: bump goauthentik/fips-python from `72f6e14` to `8fd04de` in /lifecycle/container (#27920) root: require Node.js 24.22.3 (#27906) admin/files, core: read the cached icon URLs of a list in one query (#27695) core: bump pnpm to 12.22.0 everywhere (#27905) web/elements: fix the wizard next button staying disabled (#27660) events, tasks: speed up the event and task queries (#27692) core: bump the pnpm group across 2 directories with 1 update (#26843) core: bump astral-sh/uv from 0.13.8 to 0.13.9 in /lifecycle/container (#27893) core: bump aws-cdk-lib from 2.275.0 to 2.276.0 (#27899) core: bump jsonpatch from 1.44 to 1.46 (#27898) core: bump cachetools from 7.3.1 to 7.3.2 (#27897) core: bump google-api-python-client from 2.201.0 to 2.202.0 (#27896) core: bump goauthentik/fips-python from `96730cd` to `72f6e14` in /lifecycle/container (#27894) ci: bump taiki-e/install-action from 2.90.3 to 2.90.4 in /.github/actions/setup (#27895) core: bump goauthentik/fips-debian from `56dbb46` to `712d5d1` in /lifecycle/container (#27892) core: bump github.com/grafana/pyroscope-go from 1.4.3 to 1.5.0 (#27891) providers/saml: add option to ignore ForceAuthn from the SP (#27057) Reviewer's request: deleting yourself only deserves a warning. ...
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.

Details
What does this PR change?
the event and task pages in the admin UI scanned the whole events table, so on big installs they took seconds to load. now they use indexes. the api response format and schema stay the same.
appindex via a newdistinct_values()helper, instead ofSELECT DISTINCT app?action=: finds matching actions, then filters withaction IN (...). the action filter and app autocomplete both use Unicode case folding.?actions=and taskaggregated_status:distinct=False, they filter on the model's own columndate_bin('6 hours', ...)andcount(*), so postgres counts from the coveringcreatedindexcontext. same resulttasklogsin python instead of calling.filter(), which threw the prefetch awaymtime INCLUDE (aggregated_status)index, the status index alone read every matching task(user, created) WHERE NOT seenevent indexes shrink about 9% at 10M. the model pk index isn't partial on purpose: postgres only uses stats from non-partial expression indexes, and a partial one picked a bad plan for changelogs.
index changes
events (one migration):
user(whole json) andcontext -> 'authorized_application'(whole object), nothing queries themcreatedbecomescreated INCLUDE (action, expires, expiring)context #> '{authorized_application,pk}', created(partial),context #> '{model,pk}', action,context -> 'username'(partial),user -> 'username'user(whole JSON object)context -> 'authorized_application'(whole object)createdcreated INCLUDE (action, expires, expiring)context #> '{authorized_application,pk}', createdcontext #> '{model,pk}', actioncontext -> 'username'user -> 'username'tasks (one migration):
(rel_obj_content_type, rel_obj_id)getsmtimeadded, plus newaggregated_status,mtimeandmtime INCLUDE (aggregated_status) WHERE rel_obj_id IS NULLindexes. +46 MB at 500k tasks.writes: inserting 500k events was a bit faster than main (15.8s vs 17.7s) since dropping the
userindex outweighs the new ones.the event index migration took 66 seconds at 10 million events. event writes wait while it runs. the 2026.11 release notes call out the lock.
Why is this change needed?
at 10M events a changelog took 12s to load.
How was this tested?
added tests for the action filter, Unicode matching for custom actions, distinct values on an unfiltered queryset, app suggestions skipping expired events, top apps per user, volume buckets starting at midnight UTC, task list query count (fails on main), and filtering tasks by content type + id.
seeded 10k to 10M events over 365 days with power law users. at 10M:
user.username = ...)at 10k events everything's the same or slightly faster.
all numbers
10M events:
user.username = ...)1M events:
user.username = ...)100k events:
user.username = ...)10k events:
user.username = ...)Checklist
make all)make docs)