Skip to content

Useless SPARQL queries for concept labels #1799

@osma

Description

@osma

URL address of the page where you encountered the problem

http://localhost/Skosmos/finaf/fi/search?clang=fi&q=aaron

http://localhost/Skosmos/finaf/fi/page?uri=http%3A%2F%2Furn.fi%2FURN%3ANBN%3Afi%3Aau%3Afinaf%3A000224268

Description of the problem

Skosmos performs a lot of SPARQL queries, many of which seem to be useless or redundant. This happens in particular on the search results page, but also to some extent on the concept page. There are many SPARQL queries that query for the label of a particular URI (via the GenericSparql->queryLabel() method). In some cases the same query is performed repeatedly while processing the same request.

FWIW, I first tried to address this in PRs #1796 (and #1798 for Skosmos 2) which adds a SPARQL query result cache, but after some more research, I think those are just papering over the real problem - most of the queries should be avoided in the first place, and a cache is probably not useful after fixing that.

Additional information (e.g. screenshots) about the problem

Here are known cases of useless queries:

  1. ConceptPropertyValue.__construct() calls $this->getLabel() to determine if a concept is external to the current vocabulary. But getLabel() often falls back to calling getExternalLabel(), resulting in a SPARQL query. That should not be necessary for finding out whether the concept is external, so it could be avoided.

  2. Concept.getProperties() ends up performing many getLabel() / queryLabel() calls, especially when displaying concepts like "Aaron (Raamatun henkilö)" (see URLs above) which contains a lot of links to other URI namespaces (mts, viaf, yso, lexvo...). These are probably necessary when displaying the concept page, but not when displaying the concept on the search results page, which won't display most of the linked information to the user.

There could be other useless queries as well, this is just scratching the surface.

The browser you used when the problem appeared

Firefox or curl, doesn't matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions