Skip to content

Cache SPARQL query results to avoid repeated identical queries#1796

Merged
osma merged 1 commit intomainfrom
sparql-query-cache
Aug 21, 2025
Merged

Cache SPARQL query results to avoid repeated identical queries#1796
osma merged 1 commit intomainfrom
sparql-query-cache

Conversation

@osma
Copy link
Member

@osma osma commented Aug 19, 2025

Reasons for creating this PR

While debugging performance issues in global search, I noticed that Skosmos sometimes performs several identical SPARQL queries in a row, especially queries for concept labels. This is a waste of time and resources, even if the query can often be served from a HTTP cache (e.g. varnish or nginx).

This PR adds a simple SPARQL query cache that stores results for the duration of a single request. It improves the performance of some global search queries that return many hits from different vocabularies.

Note: This should probably be backported to Skosmos 2 as well. It should be very easy because the GenericSparql code is the same.

Link to relevant issue(s), if any

  • n/a

Description of the changes in this PR

  • Add query cache within GenericSparql class

Known problems or uncertainties in this PR

None.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added this to the 3.0-beta.1 milestone Aug 19, 2025
@osma osma self-assigned this Aug 19, 2025
@osma osma force-pushed the sparql-query-cache branch from d29b6d5 to 370962a Compare August 19, 2025 12:40
@sonarqubecloud
Copy link

Copy link
Contributor

@joelit joelit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I didn't manage to set up a waterproof test case to see the improvements though.

@osma osma merged commit edcff22 into main Aug 21, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Issue/PR closed in Skosmos 3.x Backlog Aug 21, 2025
@osma osma deleted the sparql-query-cache branch August 21, 2025 09:30
@osma osma mentioned this pull request Aug 26, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants