Sparql r据我所知,这算什么。出于您的兴趣,我通过CONSTRUCTquery下载了相关的数据子集,然后使用旧的Apache Jena CLI,它在~11s内返回结果。@medianhill我明白了。但即使是第二个子查询也会导致超时。考虑到在聚合之前只剩下两个必须

Sparql r据我所知,这算什么。出于您的兴趣,我通过CONSTRUCTquery下载了相关的数据子集,然后使用旧的Apache Jena CLI,它在~11s内返回结果。@medianhill我明白了。但即使是第二个子查询也会导致超时。考虑到在聚合之前只剩下两个必须,sparql,wikidata,Sparql,Wikidata,r据我所知,这算什么。出于您的兴趣,我通过CONSTRUCTquery下载了相关的数据子集,然后使用旧的Apache Jena CLI,它在~11s内返回结果。@medianhill我明白了。但即使是第二个子查询也会导致超时。考虑到在聚合之前只剩下两个必须完成的连接,我看不到任何可能的优化。@AKSW是的,它可能只选择了第一个值。未测试,但我假设sample返回由group_concat返回的连接的第一部分。 # Average duration of films, grouped by


r据我所知,这算什么。出于您的兴趣,我通过
CONSTRUCT
query下载了相关的数据子集,然后使用旧的Apache Jena CLI,它在~11s内返回结果。@medianhill我明白了。但即使是第二个子查询也会导致超时。考虑到在聚合之前只剩下两个必须完成的连接,我看不到任何可能的优化。@AKSW是的,它可能只选择了第一个值。未测试,但我假设sample返回由group_concat返回的连接的第一部分。
    # Average duration of films, grouped by their genre and the year of publication       
SELECT  
        ?genre1                    # film genre
        ?year1                     # film year of publication
        (AVG(?duration1) AS ?avg)   # film average duration

WHERE
        {      
            # Calculating the average duration for each single film.
            # As there are films with multiple duration, these durations are 
            # averagred by grouping aggregating durations by film.
            # Hence, a single duration for each film is projected out from the subquery.
            {
              select ?film (avg(?duration) as ?duration1)  
              where{
                ?film   <http://www.wikidata.org/prop/direct/P2047>   ?duration .    
              }group by ?film
            }

            # Here the grouping criteria (genre and year) are calculated.
            # The criteria is grouped by film, so that in case multiple 
            # genre/multiple year exist for a single film, all of them are
            # group concated into a single value.
            # Also in case of a lack of a value of year or genre for some
            # specific film, a dummy value "OtherYear"/"OtherGenre" is generated.
            {
              select ?film (
                                IF
                                (
                                    group_concat(distinct ?year ; separator="-- ") != "", 
                                    # In case multiple year exist for a single film, all of them are group concated into a single value.
                                    group_concat(distinct ?year ; separator="-- "), 
                                   # In case of a lack of a value of year for some specific film, a dummy value "OtherYear" is generated.
                                    "OtherYear"                                        
                                )
                                as ?year1
                              )
                                (
                                IF
                                (
                                    group_concat(distinct ?genre ; separator="-- ") != "",
                                    # In case multiple genre exist for a single film, all of them are group concated into a single value.
                                    group_concat(distinct ?genre ; separator="-- "), 
                                    # In case of a lack of a value of genre for some specific film, a dummy value "OtherGenre" is generated.
                                    "OtherGenre"  
                                )
                                as ?genre1
                              ) 

              where 
              {
                ?film  <http://www.wikidata.org/prop/direct/P31>  <http://www.wikidata.org/entity/Q11424> .
                 optional {
                   ?film   <http://www.wikidata.org/prop/direct/P577>  ?date .
                   BIND(year(?date) AS ?year)
                 }
                 optional {
                   ?film <http://www.wikidata.org/prop/direct/P136>  ?genre .
                 }
              } group by ?film              
          }

        } GROUP BY ?year1 ?genre1
    (sample(?year) as ?year1)
    (sample(?genre) as ?genre1)