我正在针对Blazegraph在Wikidata query service RDF Graph数据库上执行SPARQL查询。这些查询涉及多个UNION,通常是FILTER之类的
SELECT DISTINCT ?music_track ?music_trackLabel ?artist ?artistLabel ?album ?albumLabel ?publication_date WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
{ ?music_track wdt:P31 wd:Q134556. }
UNION
{ ?music_track wdt:P31 wd:Q7366. }
UNION
{ ?music_track wdt:P31 wd:Q2188189. }
UNION
{ ?music_track wdt:P31 wd:Q207628. }
UNION
{ ?music_track wdt:P31 wd:Q7302866. }
UNION
{ ?music_track wdt:P31 wd:Q9748. }
UNION
{ ?music_track wdt:P2207 ?_spotifyTrackID_. }
?music_track rdfs:label ?music_trackLabel.
?music_track wdt:P175 ?artist.
?artist rdfs:label ?artistLabel.
OPTIONAL { ?music_track wdt:P361 ?album.}
OPTIONAL { ?music_track wdt:P577 ?publication_date. }
FILTER regex(?music_trackLabel, "^Castle on the Hill$", "i")
FILTER (regex(?artistLabel, "ed sheeran", "i"))
}
LIMIT 10
或喜欢
SELECT DISTINCT ?artist ?artistLabel ?birth_nameLabel ?date ?website ?instagramID ?facebookID ?twitterID ?musicBrainzArtistID WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
{ ?artist wdt:P31 wd:Q215380. }
UNION
{ ?artist wdt:P31 wd:Q2088357. }
UNION
{ ?artist wdt:P31 wd:Q5741069. }
UNION
{ ?artist wdt:P31 wd:Q641066. }
UNION
{ ?artist wdt:P1902 ?_spotifyArtistID_. }
UNION
{ ?artist wdt:P2850 ?_itunesArtistID_. }
UNION
{ ?artist wdt:P434 ?musicBrainzArtistID. }
FILTER(REGEX(?artistLabel, "^Fall Out Boy$", "i"))
?artist rdfs:label ?artistLabel.
OPTIONAL { ?artist wdt:P571 ?date. }
OPTIONAL { ?artist wdt:P1477 ?birth_nameLabel. }
OPTIONAL { ?artist wdt:P856 ?website. }
OPTIONAL { ?artist wdt:P2003 ?instagramID. }
OPTIONAL { ?artist wdt:P2013 ?facebookID. }
OPTIONAL { ?artist wdt:P2002 ?twitterID. }
}
LIMIT 10
那些查询非常慢(从几秒钟到十多秒钟不等),我想优化这些查询。
使用Blazegraph仪表板,我做了一个查询EXPLAIN,但是我没有了解如何以及如何优化。