Repository navigation
perf(stats): count all active-user windows in one query - #1235
Open
karlitschek wants to merge 1 commit into
Open
karlitschek wants to merge 1 commit into
karlitschek wants to merge 1 commit into
Conversation
karlitschek
force-pushed
the
feat/os-status-collector
branch
from
October 25, 2026 19:19
6d327c2 to
34014ec
Compare
karlitschek
force-pushed
the
perf/active-users-one-query
branch
from
October 25, 2026 19:25
736435f to
9e3d6d8
Compare
getSessionStatistics() ran one COUNT per time window, eight queries that each cast configvalue over every login/lastLogin row of oc_preferences. On an instance with a million users that is eight million row reads per monitoring call. Select the eight windows as SUM(CASE WHEN ... THEN 1 ELSE 0 END) columns of a single query over the same rows. Each CASE uses the same castColumn() comparison as before, so the counts match the old per-window queries on every database, including the string and non-numeric quirks of SQLite and MySQL. SUM over no rows is NULL and maps to 0. The output keys, their order and the int values stay the same. The seen-users count in StorageStatistics already comes from IUserManager::countSeenUsers(), a plain COUNT over the (appid, configkey) index without a cast, so it stays as it is. The tests compare the result with the old per-window queries, and cover users exactly at and one second outside each cutoff, non-numeric and empty values, no lastLogin rows at all, and the seen-users count. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
karlitschek
force-pushed
the
perf/active-users-one-query
branch
from
October 25, 2026 19:45
9e3d6d8 to
fa3e347
Compare
karlitschek
marked this pull request as ready for review
October 25, 2026 20:25
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.
Based on
feat/os-status-collector(#1214).AI disclosure: this change was written with Claude Code (claude-opus-5-5) and is to be reviewed by the author before it leaves draft; every commit carries an
Assisted-bytrailer.🤖 Generated with Claude Code