Try changing the first part of your request to use UNION for example.
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbp: <http://dbpedia.org/property/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT * WHERE { { ?uri rdfs:label ?label . } UNION { [] dbo:wikiPageRedirects ?uri . ?uri rdfs:label ?label . } OPTIONAL { ?uri geo:lat ?lat ; geo:long ?long } OPTIONAL { ?uri dbo:country ?dbpediaContry . ?dbpediaContry dbp:cctld ?ccTLD } FILTER (SAMETERM(?uri, <URL>) && lang(?label) = "en" ) }
UNION allows you to find objects that have URIs and those that have URIs through redirection, and then apply the rest of your query. Note. I also changed your FILTER to use SAMETERM() , which should speed up the request.
In general, if you have such a request, when you do this type of FILTER to set a constant, I would strongly recommend that you replace all use of the variable ?uri <URL> instead, which should see much better performance
Robv source share