Let's say I want to retrieve the "sex or gender" (P21
) of all people (i.e. human = Q5
) that has an IMDb ID (P345
) from Wikidata
I could get the total list which is nearly 444k lines in less than 20 seconds with the following query
SELECT DISTINCT ?item ?imdb ?gender WHERE {
?item wdt:P31 wd:Q5;
wdt:P345 ?imdb;
wdt:P21 ?gender.
}
but if I want the English gender label ("male" instead of Q6581097
) in my results, the request takes too long and fail with a "Query timeout limit reached
"
SELECT DISTINCT ?item ?imdb ?gender ?genderLabel WHERE {
?item wdt:P31 wd:Q5;
wdt:P345 ?imdb;
wdt:P21 ?gender.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Q: Is there a way to optimize the query so that getting the corresponding value (joining) of a Property doesn't take much longer to compute?
I've tried to filter the label gender in English (which BTW might have been the case) as explained here without much result
?gender rdfs:label ?genderLabel. FILTER( LANG(?genderLabel)="en" )
and I've also tried to be more specific as explained here with the following:
?item wdt:P31+ wd:Q5;
but this is the a plain 1-to-1 mapping of property (no fuzzy)
NB: as of today there is about 30 different P21
(gender) properties for the 443851 lines