Repository navigation
FIX: Keep SQLite analytics filter values within the facet budget - #4811
Open
Behnam (behnam-o) wants to merge 1 commit into
Open
Behnam (behnam-o) wants to merge 1 commit into
Behnam (behnam-o) wants to merge 1 commit into
Conversation
SQLite copies every column a GROUP BY key references into its sorter, including embedded identifier JSON that only never-taken fallbacks read. Scalar facets with derived keys (Operation, scenario, attack type, objective target) grouped those expressions directly, so on a database with about 11K results the objective-target and attack-type facets took about 1.7 seconds and always exceeded the 1-second facet budget. Group a materialized projection of each result's kind, key, and label instead, as the SQL Server path already does with its lateral projection. Facet options are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified that would block approval.
No open issues 🎉
What changed in this PR
Improves SQLite analytics facet performance by grouping projected keys and labels rather than carrying embedded identifier JSON through sorting, without changing facet options.
Changes:
- Materializes projections for Operation, scenario, attack type, and objective target facets.
- Adds SQL compilation checks for all four dimensions.
- Documents the optimization and SQLite version behavior.
| File | Description |
|---|---|
| tests/unit/memory/test_attack_analytics.py | Verifies materialized projections and grouping on SQLite. |
| pyrit/memory/attack_analytics_query.py | Projects scalar facet keys and labels before grouping. |
| doc/code/analytics/0_attack_results.md | Explains how projections reduce SQLite sorting overhead. |
Review effort: Balanced
This branch has not been deployed
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.
Description
On SQLite, the analytics filter values for Operation, scenario, attack type, and objective target can time out on moderately large databases. Their facet queries group expressions whose fallbacks reference each result's embedded identifier JSON, and SQLite copies every referenced column into its GROUP BY sorter for every row, even though those fallbacks are never taken. This PR keeps these facets well within the 1-second facet budget.
Measured through the backend against a local SQLite database with 10,777 attack results (about 10 KB of identifier JSON each), with the default 1-second facet budget:
Facets still read every result in the filtered cohort, so much larger SQLite databases can still exceed the budget (about 1.1–1.2 s at 32K results); that is not addressed here. Related: #4790 fixes report heatmap timeouts on Azure SQL, a separate path.