Skip to content

Add for_occurrences and with_advisory scopes

Zamir Martins requested to merge add_for_occurrences_scope into master

What does this MR do and why?

Add for_occurrences and with_advisory scopes for pm_affected_packages. This will be used for fetching pm_affected_packages as required by CVS on SBOM change (#464575) • Zamir Martins • 17.2

Related issue: #464575

Query plan

The following queries were run with the input of 1242 records (under CTE). Amount of returned records was 903.

Query plan before the following index:

CREATE INDEX index_pm_affected_packages_purl_type_package_name ON pm_affected_packages USING btree (purl_type, package_name)

Query plan after the creation of the index:

Time: 10.525 ms
  - planning: 3.246 ms
  - execution: 7.279 ms
    - I/O read: 2.644 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 4254 (~33.20 MiB) from the buffer pool
  - reads: 105 (~840.00 KiB) from the OS file cache, including disk I/O
  - dirtied: 40 (~320.00 KiB)
  - writes: 0

Index will be created as part of Add index_purl_type_package_name_on_pm_affected... (!158792) • Zamir Martins • 17.2

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

> occurrences = Sbom::Occurrence.limit(50)
> PackageMetadata::AffectedPackage.for_occurrences(occurrences)

Numbered steps to set up and validate the change are strongly suggested.

Edited by Zamir Martins

Merge request reports