Skip to content

perf(db): add index on sbom_external_node(sbom_id, external_node_ref)#2404

Draft
mrrajan wants to merge 1 commit into
guacsec:mainfrom
mrrajan:TC-4750
Draft

perf(db): add index on sbom_external_node(sbom_id, external_node_ref)#2404
mrrajan wants to merge 1 commit into
guacsec:mainfrom
mrrajan:TC-4750

Conversation

@mrrajan

@mrrajan mrrajan commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Eliminates sequential scan during external node resolution. Verified: Seq Scan → Index Scan on hosted environment.

Implements TC-4750

Assisted-by: Claude Code

Summary by Sourcery

Enhancements:

  • Introduce a migration that adds a composite index on sbom_external_node(sbom_id, external_node_ref) to optimize query performance.

Eliminates sequential scan during external node resolution.
Verified: Seq Scan → Index Scan on hosted environment.

Implements TC-4750

Assisted-by: Claude Code
@sourcery-ai

sourcery-ai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a new SeaORM migration to create a composite index on sbom_external_node(sbom_id, external_node_ref) and wires it into the migrator so external node resolution can use an index scan instead of a sequential scan.

File-Level Changes

Change Details Files
Introduce a new SeaORM migration that creates/drops a composite index on sbom_external_node over (sbom_id, external_node_ref) and register it in the global migrator.
  • Register a new migration module m0002200_sbom_external_node_ref_index in the migration library and add it to the Migrator::build_migrations chain as a normal migration.
  • Define the Migration::up implementation to create an if-not-exists index named IdxSbomExternalNodeRef on the SbomExternalNode table over SbomId and ExternalNodeRef using SeaORM’s Index builder.
  • Define the Migration::down implementation to drop the index if it exists, mirroring the up migration.
  • Introduce DeriveIden enums (Indexes and SbomExternalNode) to provide identifier names for the index and table/columns in a type-safe way.
migration/src/lib.rs
migration/src/m0002200_sbom_external_node_ref_index.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.39%. Comparing base (5f31950) to head (f3daf1c).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2404      +/-   ##
==========================================
+ Coverage   71.37%   71.39%   +0.01%     
==========================================
  Files         441      442       +1     
  Lines       26747    26896     +149     
  Branches    26747    26896     +149     
==========================================
+ Hits        19092    19202     +110     
- Misses       6541     6565      +24     
- Partials     1114     1129      +15     

☔ View full report in Codecov by Harness.
📢 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.

@rh-jfuller

Copy link
Copy Markdown
Contributor

@mrrajan considering current and ongoing work on 0.4.z (which will push to main) I think this PR can be closed ... do you agree ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants