query-6b0534482ddb28b3caba11dc5826cda3
]reply[09:34, 6 June 2020 (UTC)) talk (Dipsacus fullonumAn obvious optimization is to remove the OPTIONAL keywords. You need results from the OPTIONAL clauses to get values for ?brand and ?item, so the aren't really optional. That being said I don't think it will be possible to avoid timeout because there are far too many results. My counting gave 171,070 companies, 11,760 products and over a million items. You will need to limit the query to get a smaller result by adding more restrictive criteria. An general search for all types of products at once is impossible in 60 seconds. --:: Thank you very much. In fact, I removed the OPTIONAL KeyWord. But I still faced a problem of redundancy. In the following Query, the field ?ProductsItemName contains redundant data and when i used Distinct KeyWord, the query generates an Exception. Help me in eliminating the redundancy.Dipsacus fullonum, Dipsacus fullonum@
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
select ?brand ?brandLabel (GROUP_CONCAT(?itemName; SEPARATOR=", ") AS ?ProductsItemName)
where {
?CompanyID wdt:P31 wd:Q4830453.
?CompanyID wdt:P1056 ?MaterialProduced.
?item wdt:P279* ?MaterialProduced.
?item wdt:P1716 ?brand.
SERVICE wikibase:label{
bd:serviceParam wikibase:language "en".
?item rdfs:label ?itemName.
?brand rdfs:label ?brandLabel.
}
}
GROUP BY ?brand ?brandLabel