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

GraphDB does not optimize away un-selected OPTIONAL clauses #166

Open
kevinstadler opened this issue Dec 9, 2024 · 1 comment
Open

GraphDB does not optimize away un-selected OPTIONAL clauses #166

kevinstadler opened this issue Dec 9, 2024 · 1 comment
Assignees

Comments

@kevinstadler
Copy link

kevinstadler commented Dec 9, 2024

DISTINCT and COUNT queries like

PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX lrmoo: <http://iflastandards.info/ns/lrm/lrmoo/>
PREFIX star: <https://r11.eu/ns/star/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX r11: <https://r11.eu/ns/spec/>
PREFIX r11pros: <https://r11.eu/ns/prosopography/>

select (count(distinct ?person) as ?cnt)

WHERE {
?person a crm:E21_Person.
  OPTIONAL {  ?person__person_id_assignment a crm:E15_Identifier_Assignment.  ?person ^crm:P140_assigned_attribute_to ?person__person_id_assignment.  }
  OPTIONAL {  ?person__person_appellation_assertion a star:E13_crm_P1.  ?person ^crm:P140_assigned_attribute_to ?person__person_appellation_assertion.      ?person__person_appellation_assertion crm:P141_assigned ?person__person_appellation_assertion___pai.    ?person__person_appellation_assertion___pai crm:P190_has_symbolic_content ?person__person_appellation_assertion__person_appellation_is.  }
  OPTIONAL {  ?person__person_gender_assertion a star:E13_crm_P41.  ?person ^crm:P141_assigned ?person__person_gender_assertion.  }
  OPTIONAL {  ?person__person_ethnicity_assertion a star:E13_crm_P107.  ?person ^crm:P141_assigned ?person__person_ethnicity_assertion.  }
  OPTIONAL {  ?person crm:P3_has_note ?person__person_descriptive_name.  }
  OPTIONAL {  ?person__person_possession_assertion a star:E13_crm_P51.  ?person ^crm:P141_assigned ?person__person_possession_assertion.  }
  OPTIONAL {  ?person__person_status_assertion a star:E13_sdhss_P26.  ?person ^crm:P141_assigned ?person__person_status_assertion.  }
  OPTIONAL {  ?person__person_religion_assertion a star:E13_sdhss_P36.  ?person ^crm:P141_assigned ?person__person_religion_assertion.  }
  OPTIONAL {  ?person__person_occupation_assertion a star:E13_sdhss_P13.  ?person ^crm:P141_assigned ?person__person_occupation_assertion.  }
  OPTIONAL {  ?person__person_language_assertion a star:E13_sdhss_P38.  ?person ^crm:P140_assigned_attribute_to ?person__person_language_assertion.  }
  OPTIONAL {  ?person__person_kinship_assertion a star:E13_sdhss_P17.  ?person ^crm:P141_assigned ?person__person_kinship_assertion.  }
}

take ages to execute, even though the simple query

 PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX lrmoo: <http://iflastandards.info/ns/lrm/lrmoo/>
PREFIX star: <https://r11.eu/ns/star/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX r11: <https://r11.eu/ns/spec/>
PREFIX r11pros: <https://r11.eu/ns/prosopography/>

select (count(distinct ?person) as ?cnt)

WHERE {
?person a crm:E21_Person.
}

would yield the same result.

Suggested fix: rdfproxy should strip OPTIONAL clauses during query injection.

@kevinstadler kevinstadler added the bug Something isn't working label Dec 9, 2024
@lu-pl lu-pl self-assigned this Dec 9, 2024
@kevinstadler kevinstadler changed the title SPARQLWrapper slows down complex queries GraphDB does not optimize OPTIONAL clauses out of nested queries Dec 10, 2024
@kevinstadler kevinstadler changed the title GraphDB does not optimize OPTIONAL clauses out of nested queries GraphDB does not optimize OPTIONAL clauses out of COUNT queries Dec 10, 2024
@kevinstadler kevinstadler changed the title GraphDB does not optimize OPTIONAL clauses out of COUNT queries GraphDB does not optimize away un-selected OPTIONAL clauses Dec 10, 2024
@lu-pl lu-pl removed the bug Something isn't working label Dec 11, 2024
@lu-pl
Copy link
Contributor

lu-pl commented Dec 11, 2024

Removed bug label. This is not an RDFProxy bug.

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

No branches or pull requests

2 participants