Sparql query getting timeout exception

Shajedul Islam Any :

When I am using this query in java then I am getting HTTP Exception 504 as I am getting data from Live.

But if I remove influenced or influencedBy or Paradigm or anyone of them then it works fine. Then I understood that there is a problem in time or in memory and another problem is now it is too slow. I want them all. What can I do now?

SELECT  ?pl  ?pl_label ?abstract ?_thumbnail

           ( group_concat ( DISTINCT ?_influenced_label; separator="; " )   AS ?influenced )
           ( group_concat ( DISTINCT ?_influencedBy_label; separator="; " ) AS ?influencedBy ) 
           ( group_concat ( ?_sameAs; separator=", " ) AS ?sameAs )     
           ( group_concat ( ?_paradigm_label; separator=", " ) AS ?paradigm )

    WHERE
      { 

          ?pl   rdf:type    dbo:ProgrammingLanguage .

          OPTIONAL  { ?pl   dbo:abstract    ?abstract . 

          FILTER ( LANG ( ?abstract ) = 'en' ) . }

          ?pl   rdfs:label      ?pl_label

          FILTER ( LANG ( ?pl_label ) = 'en' ) .

          OPTIONAL      { ?pl   dbo:influenced  ?_influenced . 

          ?_influenced      rdfs:label      ?_influenced_label . 

          FILTER ( LANG ( ?_influenced_label ) = 'en' ) . }

          OPTIONAL  { ?pl   dbo:influencedBy    ?_influencedBy . 

          ?_influencedBy  rdfs:label         ?_influencedBy_label

          FILTER ( LANG ( ?_influencedBy_label ) = 'en' ) . }

          OPTIONAL { ?pl owl:sameAs ?_sameAs . } 

          OPTIONAL { ?pl dbp:paradigm ?_paradigm .

          ?_paradigm rdfs:label ?_paradigm_label . }

          OPTIONAL { ?pl dbo:thumbnail ?_thumbnail . }

      } 
    GROUP BY ?pl ?pl_label ?abstract ?_thumbnail
TallTed :

There is a dirty data issue in the current http://live.dbpedia.org/sparql, such that there are values from multiple ingestions (i.e., multiple edits of the Wikipedia source page) for some predicates (including dbo:abstract, dbo:influenced, and dbo:influencedBy), where there should only be the most recently ingested value (i.e., the latest edit). This means that your result set will include something of a Cartesian product -- with some rows that are duplicates except for the predicate(s) that incorrectly deliver multiple versions.

Modulo that data issue, this query (with more than just an additional DISTINCT!) will deliver what I believe you now want --

SELECT  DISTINCT                                                             ?pl  
                                                                             ?pl_label 
                                                                             ?abstract 
                                                                             ?_thumbnail
        ( group_concat ( DISTINCT ?_influenced_label   ; separator="; " ) AS ?influenced )
        ( group_concat ( DISTINCT ?_influencedBy_label ; separator="; " ) AS ?influencedBy ) 
        ( group_concat ( DISTINCT ?_sameAs             ; separator=", " ) AS ?sameAs )     
        ( group_concat ( DISTINCT ?_paradigm_label     ; separator=", " ) AS ?paradigm )

WHERE
      { 
                      ?pl               rdf:type            dbo:ProgrammingLanguage ;
                                        rdfs:label          ?pl_label
                      FILTER ( LANG ( ?pl_label ) = 'en' ) .

          OPTIONAL  { ?pl               dbo:abstract        ?abstract . 
                      FILTER ( LANG ( ?abstract ) = 'en' ) . }

          OPTIONAL  { ?pl               dbo:influenced      ?_influenced . 
                      ?_influenced      rdfs:label          ?_influenced_label . 
                      FILTER ( LANG ( ?_influenced_label ) = 'en' ) . }

          OPTIONAL  { ?pl               dbo:influencedBy    ?_influencedBy . 
                      ?_influencedBy    rdfs:label          ?_influencedBy_label
                      FILTER ( LANG ( ?_influencedBy_label ) = 'en' ) . }

          OPTIONAL  { ?pl               owl:sameAs          ?_sameAs . } 

          OPTIONAL  { ?pl               dbp:paradigm        ?_paradigm .
                      ?_paradigm        rdfs:label          ?_paradigm_label 
                      FILTER ( LANG ( ?_paradigm_label ) = 'en' ) . }

          OPTIONAL { ?pl                dbo:thumbnail       ?_thumbnail . }

      } 

GROUP BY ?pl ?pl_label ?abstract ?_thumbnail

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=158566&siteId=1