Thanks for the very detailed answer Ivan! Your suggestion indeed works. Best, y
On Tue, Sep 6, 2011 at 9:37 AM, Ivan Mikhailov <imikhai...@openlinksw.com> wrote: > Hello Yves, > > Virtuoso knows that > > FILTER (str(?uri) = 'http://dbpedia.org/resource/London') > > is equivalent to > > FILTER ( > (isLITERAL(?uri) && (str(?uri) = > 'http://dbpedia.org/resource/London')) || > (isIRI(?uri) && ?uri = iri('http://dbpedia.org/resource/London'))) > > Then it proves that if ?uri is bound then it is bound in _subject_ position > of a triple pattern, > hence > isLITERAL(?uri) is false and thus > (isLITERAL(?uri) && (str(?uri) = 'http://dbpedia.org/resource/London')) is > false > and the condition is simplified into simpler > > FILTER (?uri = iri('http://dbpedia.org/resource/London')) > > that is actually a user-friendly > > FILTER (?uri = <http://dbpedia.org/resource/London>) > > Then Virtuoso propagates the equivalence across the query so it becomes > the equivalent of > > select (<http://dbpedia.org/resource/London>) as ?uri , ?subject > where { > <http://dbpedia.org/resource/London> <http://purl.org/dc/terms/subject> > ?subject > } > > That's why it's so fast. > > > The first query can also be fast, with different wording. > I'd replace the combination of str() and || with index-friendly IN operator: > > select ?uri ?subject > where { > ?uri <http://purl.org/dc/terms/subject> ?subject > FILTER (?uri in ( > <http://dbpedia.org/resource/London>, > <http://dbpedia.org/resource/Family_(biology)> ) ) > } > > > I will extend the optimizer so it will be able to deal with that "||" > better, but not right now, because even the current version replaces > "||" with "IN" for many typical uses. E.g. "||" in > > select ?uri ?subject where { > FILTER ( > ?uri = <http://dbpedia.org/resource/London> || > ?uri = <http://dbpedia.org/resource/Family_(biology)> ) > ?uri <http://purl.org/dc/terms/subject> ?subject } > > is optimized into "IN" automatically and runs quite ok. > > > Best Regards, > > Ivan Mikhailov > OpenLink Software > http://virtuoso.openlinksw.com > > > > On Mon, 2011-09-05 at 12:23 +0100, Yves Raimond wrote: >> Hello! >> >> I noticed the following weird behavior on the public DBpedia endpoint: >> >> """ >> select ?uri ?subject >> where { >> FILTER (str(?uri) = 'http://dbpedia.org/resource/London' || str(?uri) >> = 'http://dbpedia.org/resource/Family_(biology)') >> ?uri <http://purl.org/dc/terms/subject> ?subject >> } >> """ >> >> hangs forever, while >> >> """ >> select ?uri ?subject >> where { >> FILTER (str(?uri) = 'http://dbpedia.org/resource/London') >> ?uri <http://purl.org/dc/terms/subject> ?subject >> } >> """ >> >> is very quick. >> >> Looking at the queries, the earlier seems of approximately the same >> complexity as the latter? >> >> Best, >> y > > > ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev _______________________________________________ Dbpedia-discussion mailing list Dbpedia-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion