{"action":"created","issue":{"url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/729","repository_url":"https://api.github.com/repos/openlink/virtuoso-opensource","labels_url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/729/labels{/name}","comments_url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/729/comments","events_url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/729/events","html_url":"https://github.com/openlink/virtuoso-opensource/issues/729","id":305189867,"number":729,"title":"Is there a way to optimize this particular query?","user":{"login":"steffres","id":35728628,"avatar_url":"https://avatars0.githubusercontent.com/u/35728628?v=4","gravatar_id":"","url":"https://api.github.com/users/steffres","html_url":"https://github.com/steffres","followers_url":"https://api.github.com/users/steffres/followers","following_url":"https://api.github.com/users/steffres/following{/other_user}","gists_url":"https://api.github.com/users/steffres/gists{/gist_id}","starred_url":"https://api.github.com/users/steffres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steffres/subscriptions","organizations_url":"https://api.github.com/users/steffres/orgs","repos_url":"https://api.github.com/users/steffres/repos","events_url":"https://api.github.com/users/steffres/events{/privacy}","received_events_url":"https://api.github.com/users/steffres/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-14T14:46:13Z","updated_at":"2018-03-14T15:05:12Z","closed_at":null,"author_association":"NONE","body":"Hi all, \r\n  \r\nWe have a working query for the following case, but it becomes very slow when querying our productive dataset. \r\n\r\nBasically we want to have the triples returned where the subjects have <rdf:type> property defined somewhere, but we don't want _only the triples returned where these type properties are defined_. e.g. assuming the following data:\r\ns1 - rdf:type - t1\r\ns1 - p - o1\r\ns2 - p - o2\r\n\r\nSo we want to have returned:\r\ns1 - rdf:type - t1\r\ns1 - p - o1\r\nsince s1 has type property while s2 doesn't.\r\n\r\nOur sparql query which works on small datasets but not very well on large sets (for 7 million triples it took 1 hour) is the following:\r\n\r\n`SELECT * WHERE { ?s ?p ?o . { SELECT DISTINCT (?s) WHERE { ?s a [] } } } `\r\n\r\nSo my question is if this query can be optimized in any way?\r\n\r\nCheers!"},"comment":{"url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/comments/373054234","html_url":"https://github.com/openlink/virtuoso-opensource/issues/729#issuecomment-373054234","issue_url":"https://api.github.com/repos/openlink/virtuoso-opensource/issues/729","id":373054234,"user":{"login":"TallTed","id":2559602,"avatar_url":"https://avatars0.githubusercontent.com/u/2559602?v=4","gravatar_id":"","url":"https://api.github.com/users/TallTed","html_url":"https://github.com/TallTed","followers_url":"https://api.github.com/users/TallTed/followers","following_url":"https://api.github.com/users/TallTed/following{/other_user}","gists_url":"https://api.github.com/users/TallTed/gists{/gist_id}","starred_url":"https://api.github.com/users/TallTed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TallTed/subscriptions","organizations_url":"https://api.github.com/users/TallTed/orgs","repos_url":"https://api.github.com/users/TallTed/repos","events_url":"https://api.github.com/users/TallTed/events{/privacy}","received_events_url":"https://api.github.com/users/TallTed/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T15:05:12Z","updated_at":"2018-03-14T15:05:12Z","author_association":"COLLABORATOR","body":"It's not clear what data is being assumed, in this presentation. It is helpful to use Turtle notation for sample data and sample results.\r\n\r\nIf I understand your question correctly, you want to get full descriptions of every entity which has an `rdf:type` property.  You might try something like\r\n\r\n```sparql\r\nSELECT ?s ?p ?o \r\nWHERE\r\n { ?s ?p ?o . \r\n   OPTIONAL { ?s a ?type } .\r\n   FILTER ( BOUND ( ?type ) ) \r\n }\r\n```\r\n\r\nThat returns very quickly on [DBpedia](http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&qtxt=SELECT+%3Fs+%3Fp+%3Fo+%0D%0AWHERE%0D%0A+%7B+%3Fs+%3Fp+%3Fo+.+%0D%0A+++OPTIONAL+%7B+%3Fs+a+%3Ftype+%7D+.%0D%0A+++FILTER+%28+BOUND+%28+%3Ftype+%29+%29+%0D%0A+%7D%0D%0A&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000&debug=on&run=+Run+Query+) and the [LOD Cloud Cache](http://lod.openlinksw.com/sparql?default-graph-uri=&qtxt=SELECT+%3Fs+%3Fp+%3Fo+%0D%0AWHERE%0D%0A+%7B+%3Fs+%3Fp+%3Fo+.+%0D%0A+++OPTIONAL+%7B+%3Fs+a+%3Ftype+%7D+.%0D%0A+++FILTER+%28+BOUND+%28+%3Ftype+%29+%29+%0D%0A+%7D%0D%0A&format=text%2Fhtml&timeout=30000&debug=on&run=+Run+Query+).\r\n\r\nAdding `ORDER BY ASC ( ?s )` slows the return a lot, but may be helpful to you."}}
{"actor":{"display_login":"TallTed"}}