-
Notifications
You must be signed in to change notification settings - Fork 35
chore: add sbom_node - node_id index #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Dahsboard is calling some endpoints and one of them is using a big rust function that contains the following `select`: ```sql SELECT "sbom_node"."sbom_id", "sbom_node"."node_id", "sbom_node"."name" FROM "sbom_node" WHERE "node_id" = ANY($1) ``` This is the worse query that is making dashboard page slow because the table is big and the index is not getting a hit because `node_id` is part of a composite index (with position 2) and consequently not using cache.
Reviewer's GuideAdds a dedicated single-column index on sbom_node.node_id via a new SeaORM migration to optimize a frequently used dashboard query, and wires the migration into the global migrator sequence. ER diagram for sbom_node and new node_id indexerDiagram
sbom_node {
int sbom_id
int node_id
string name
}
sbom_node_node_id_index {
int node_id
}
sbom_node ||--o{ sbom_node_node_id_index : indexed_by
Architecture/flow diagram for migration sequence with sbom_node_node_id_indexflowchart TD
subgraph MigrationRunner
A[MigrationRunner start]
B[m0001180_expand_spdx_licenses_with_mappings_function]
C[m0001190_optimize_product_advisory_query]
D[m0001200_source_document_fk_indexes]
E[m0001210_sbom_node_node_id_index]
F[MigrationRunner end]
end
A --> B --> C --> D --> E --> F
subgraph Database
T[sbom_node table]
I[sbom_node.node_id index]
end
E --> I
T -. uses .-> I
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- If sbom_node is large in production, consider using a concurrent index creation (or equivalent non-blocking option in SeaORM) to avoid long locks during the migration.
- The #[allow(deprecated)] on the Migration impl seems unnecessary here; consider removing it unless there is a specific deprecated API being used.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If sbom_node is large in production, consider using a concurrent index creation (or equivalent non-blocking option in SeaORM) to avoid long locks during the migration.
- The #[allow(deprecated)] on the Migration impl seems unnecessary here; consider removing it unless there is a specific deprecated API being used.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2131 +/- ##
==========================================
- Coverage 68.09% 68.08% -0.02%
==========================================
Files 372 373 +1
Lines 20758 20763 +5
Branches 20758 20763 +5
==========================================
+ Hits 14135 14136 +1
+ Misses 5782 5780 -2
- Partials 841 847 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/scale-test |
|
🛠️ Scale test has started! Follow the progress here: Workflow Run |
Goose ReportGoose Attack ReportPlan Overview
Request Metrics
Response Time Metrics
Status Code Metrics
Transaction Metrics
Scenario Metrics
Error Metrics
📄 Full Report (Go to "Artifacts" and download report) |
gildub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM.
The migration worked fine.
I cannot tell any improvement performance-wise regarding the dashboard as my current test set doesn't have big SBOMs volumes.
|
@gildub thanks for the review. I'm a bit afraid of introducing new indexes tbqh |
|
Folks I remember that I asked if we had scale tests for it and then I found this comment: This comment #2039 (comment) from Dejan says that
The |
Dahsboard is calling some endpoints and one of them is using a big rust function that contains the following
select:This is the worse query that is making dashboard page slow because the table is big and the index is not getting a hit because
node_idis part of a composite index (with position 2) and consequently not using cache.Summary by Sourcery
Add a database migration to improve lookup performance on sbom_node by indexing node_id.
Enhancements:
EDIT:
https://gist.github.com/helio-frota/f821493c83a2c62c248f321d5e2c738b