dotnetRDF上的VDS.RDF.Query.RdfQueryTimeoutException

问题描述

我正在dotNetRDF C#中运行SPARQL查询,并收到此错误

VDS.RDF.Query.RdfQueryTimeoutException
HResult=0x80131500
Message=Query Execution Time exceeded the Timeout of 180000ms; query aborted after 366471ms
Source=dotNetRDF

在Apache Jena和Python(rdflib)上,相同的查询性能分别为25.60秒和179.94秒。

因此,有什么方法可以增加dotNetRDF上查询的超时时间,在这里,我将封闭从LinkedMovie数据集中获取查询

PREFIX linkedmdb: <http://data.linkedmdb.org/movie/>
PREFIX dc: <http://purl.org/dc/terms/>

SELECT ?movie1 ?actor1 ?movie2 ?actor2 ?movie3 ?actor3 ?movie4 ?actor4 ?movie5
WHERE {
    # select the source and target nodes
    ?s linkedmdb:actor_name "Hugh Jackman" .
    ?t linkedmdb:actor_name "Kevin Bacon" .

    # find the five movies and the connecting actors between (make sure to filter out dupes)
    ?m1 dc:title ?movie1 ; linkedmdb:actor ?s ; linkedmdb:actor ?a1 .
    FILTER(?s != ?a1 && ?t != ?a1)

    ?m2 dc:title ?movie2 ; linkedmdb:actor ?a1 ; linkedmdb:actor ?a2 .
    FILTER(?m1 != ?m2)
    FILTER(?a1 != ?a2)
    FILTER(?s != ?a2 && ?t != ?a2)

    ?m3 dc:title ?movie3 ; linkedmdb:actor ?a2 ; linkedmdb:actor ?a3 .
    FILTER(?m1 != ?m3 && ?m2 != ?m3)
    FILTER(?a1 != ?a3 && ?a2 != ?a3)
    FILTER(?s != ?a3 && ?t != ?a3)

    ?m4 dc:title ?movie4 ; linkedmdb:actor ?a3 ; linkedmdb:actor ?a4 .
    FILTER(?m1 != ?m4 && ?m2 != ?m4 && ?m3 != ?m4)
    FILTER(?a1 != ?a4 && ?a2 != ?a4 && ?a3 != ?a4)
    FILTER(?s != ?a4 && ?t != ?a4)

    ?m5 dc:title ?movie5 ; linkedmdb:actor ?a4 ; linkedmdb:actor ?t .
    FILTER(?m1 != ?m5 && ?m2 != ?m5 && ?m3 != ?m5 && ?m4 != ?m5)

    # grab the actor names - much friendlier than the URIs
    ?a1 linkedmdb:actor_name ?actor1 .
    ?a2 linkedmdb:actor_name ?actor2 .
    ?a3 linkedmdb:actor_name ?actor3 .
    ?a4 linkedmdb:actor_name ?actor4 .
    }
    LIMIT 1

解决方法

查询超时设置是通过静态VDS.RDF.Options.QueryExecutionTimeout属性以及各个Timeout实例的SparqlQuery属性来控制的。 但是通过VDS.RDF.Options设置的全局超时总是提供一个上限(除非将其设置为0表示没有全局超时)。由于默认的全局超时为3分钟(180,000ms),因此您需要增加此全局设置,以执行更长的查询时间。

有关更改查询超时值的详细信息,请参见User Guide page on Global Options(在“查询选项”部分中)。

有关在查询过程中应用哪些优化的详细信息,请参见Developer Guide page on SPARQL optimisation