Skip to content

Conversation

@mbruhin
Copy link
Contributor

@mbruhin mbruhin commented Oct 22, 2025

Hey, I just made a Pull Request!

I saw that the highest load on my backstage DB by far was from the following query:

delete from "facts" where "id" = $1 and "timestamp" < $2
image

Which is run as part of the fact generation here.

The performance of this query is very slow for a database with a large number of entities or a large history of facts. We could see somewhat better performance by reducing the number of entities or facts per entity, but adding an index would really help.

There is currently an index on ['id', 'entity', 'timestamp'] but not on ['id', 'timestamp']. Adding this index significantly reduces the load on the DB and the overall performance of the tech insights plugin. Here are my DB metrics from when the index was added:
image
image
image

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@backstage-service backstage-service added the workspace/tech-insights Used to tag tech-insights workspace issues and pull requests label Oct 22, 2025
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-tech-insights-backend workspaces/tech-insights/plugins/tech-insights-backend patch v2.4.1

@mbruhin mbruhin marked this pull request as ready for review October 22, 2025 17:02
@mbruhin mbruhin requested review from a team, Xantier and punkle as code owners October 22, 2025 17:02
@mbruhin mbruhin requested a review from vinzscam October 22, 2025 17:02
@mbruhin mbruhin merged commit e28273e into backstage:main Oct 23, 2025
13 checks passed
@cal5barton
Copy link

@Xantier when will this be released? npm is showing that 2.4.1 was released 2 months ago and not yesterday.

image

@mbruhin
Copy link
Contributor Author

mbruhin commented Oct 24, 2025

@cal5barton It will be released when #5303 is merged as part of version 2.4.2.

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

Labels

workspace/tech-insights Used to tag tech-insights workspace issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants