This can at least make what's on search-dev shippable to production.
What I found was two things:
?catalog ?relationship ?s . is by far the most expensive thing in that query - it takes the most time, by orders of magnitude, so I changed things around so that it is called fewer times.
FILTER( CONTAINS(?author, '''{author}''')) . was taking a long time because ?author is optional. Changing it to FILTER(BOUND(?author) && CONTAINS(?author, '''{author}''')) . to check whether ?author even exists first helped.
Check whether ?author is bound and minimize calls for an expensive statement
This can at least make what's on search-dev shippable to production.
What I found was two things:
?catalog ?relationship ?s .
is by far the most expensive thing in that query - it takes the most time, by orders of magnitude, so I changed things around so that it is called fewer times.FILTER( CONTAINS(?author, '''{author}''')) .
was taking a long time because?author
is optional. Changing it toFILTER(BOUND(?author) && CONTAINS(?author, '''{author}''')) .
to check whether?author
even exists first helped. Check whether ?author is bound and minimize calls for an expensive statement