Skip to content
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

Update component metrics in project metrics update procedure #544

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

nscuro
Copy link
Member

@nscuro nscuro commented Jan 27, 2024

Description

Updates component metrics in the project metrics update procedure.

Instead of fetching component UUIDs first, then calling the UPDATE_COMPONENT_METRICS procedure for every single UUID individually, and then updating the project metrics.

The previous approach resulted in:

  • At least one SELECT query to fetch all N component UUIDs
  • N calls to UPDATE_COMPONENT_METRICS
  • N transactions, because each stored procedure call runs in its own transaction
  • One call to UPDATE_PROJECT_METRICS

Which resulted in lots of wasted resources.

Refreshing metrics for all projects in a portfolio with 400 total projects completes in 5s instead of 20s on my machine. I expect the difference to be even more drastic in deployments where the database is running on a different machine, and network latency plays a bigger role.

Addressed Issue

N/A

Additional Details

N/A

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Instead of fetching component UUIDs first, then calling the `UPDATE_COMPONENT_METRICS` procedure for every single UUID individually, and *then* updating the project metrics.

The previous approach resulted in:

* At least one `SELECT` query to fetch all N component UUIDs
* N calls to `UPDATE_COMPONENT_METRICS`
* N transactions, because each stored procedure call runs in its own transaction
* One call to `UPDATE_PROJECT_METRICS`

Which resulted in lots of wasted resources.

Refreshing metrics for all projects in a portfolio with 400 total projects completes in 5s instead of 20s on my machine. I expect the difference to be even more drastic in deployments where the database is running on a different machine, and network latency plays a bigger role.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro added the enhancement New feature or request label Jan 27, 2024
@VithikaS VithikaS merged commit 6e391f6 into main Jan 30, 2024
6 checks passed
@VithikaS VithikaS deleted the improve-project-metrics-update branch January 30, 2024 08:39
@nscuro nscuro added this to the 5.3.0 milestone Feb 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants