Is TDB the underlying database? If so is there a stats.opt file in your database directory?
I remember there being issues in the past with the statistics for rdf:type triples being wrongly prioritised. You might want to look at that file, assuming that it exists, and you try adjusting values associated with rdf:type based upon the guidance in the documentation: http://jena.apache.org/documentation/tdb/optimizer.html#statistics-rule-file Also if this is a database which is being updated then the statistics can get out of date relative to the database. You can use the commandline tdbstats tool to try regenerating this: http://jena.apache.org/documentation/tdb/optimizer.html#generating-a-statistics-file Note that you will need to stop Fuseki in order to run this as only a single process is permitted to access a TDB database at a time Rob On 26/10/2017 13:47, "Mikael Pesonen" <[email protected]> wrote: Hi, I have trouble understanding why the first query is slow and second one is fast. Using Jena Fuseki 3.4.0. So I want to get all resources that reference <some resource>, and their types: SELECT * WHERE { GRAPH ?g { ?s ?p <some resource> . ?s a ?type } } SELECT * WHERE { GRAPH ?g { ?s ?p <some resource> . ?s ?p2 ?o2 } } First one takes 5 seconds which is too slow for our application. Can it be rearranged somehow to make fast? Sorry if this is not a correct forum for this. Thanks! --
