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

Performance optimization: Prefetch schema hierarchy #77

Open
simontaurus opened this issue Oct 16, 2024 · 1 comment
Open

Performance optimization: Prefetch schema hierarchy #77

simontaurus opened this issue Oct 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@simontaurus
Copy link
Contributor

simontaurus commented Oct 16, 2024

As a heuristic, we can query the parent classes/categories (vertical) as well as referenced property characteristics (horizontal).

SMW Ask Query to get all required schemas for the instance Item:OSWff8ab0e2075040d4939ac9313a997904:

https://wiki-dev.open-semantic-lab.org/w/api.php?action=ask&query=
[[-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
OR[[-SubClassOf.-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
OR[[-SubClassOf.-SubClassOf.-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
OR[[-SubClassOf.-SubClassOf.-SubClassOf.-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
OR[[-SubClassOf.-SubClassOf.-SubClassOf.-SubClassOf.-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
OR[[-SubClassOf.-SubClassOf.-SubClassOf.-SubClassOf.-SubClassOf.-HasType::Item:OSWff8ab0e2075040d4939ac9313a997904]]
|?HasProperty.HasCharacteristic=c1
|?HasProperty.HasCharacteristic.HasQuantity=q1
|?HasProperty.HasCharacteristic.HasProperty.HasCharacteristic=c2
|?HasProperty.HasCharacteristic.HasProperty.HasCharacteristic.HasQuantity=q2
|?HasProperty.HasCharacteristic.HasProperty.HasCharacteristic.HasProperty.HasCharacteristic=c3
|?HasProperty.HasCharacteristic.HasProperty.HasCharacteristic.HasProperty.HasCharacteristic.HasQuantity=q3
&format=json

We can then fetch all returned categories/schemas in a single API call, see #78

However, currently the property path queries stop working at HasProperty.HasCharacteristic.HasProperty.HasCharacteristic.HasProperty and beyond, probably due to SemanticMediaWiki/SemanticMediaWiki#5036

@LukasGold
Copy link
Contributor

Idea: use functools.cache to reduce number of schema refetches

@LukasGold LukasGold added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants