Smalyshev edited the task description. (Show Details)

EDIT DETAILS
I notice that queries using values like https://query.wikidata.org/#SELECT%20%3Fitem%20%3Fitem2%20%3Finv%20WHERE%20%7B%0A%20%20VALUES%20%3Fcollection%20%7Bwd%3AQ28045665%20wd%3AQ28045660%20wd%3AQ28045674%20wd%3AQ2066737%20wd%3AQ18600731%20%7D%20.%20%23%20%20The%20different%20collections%0A%20%20%3Fitem%20p%3AP217%20%3Finv1statement%20.%0A%20%20%3Finv1statement%20ps%3AP217%20%3Finv%20.%0A%20%20%3Finv1statement%20pq%3AP195%20%3Fcollection%20.%20%0A%20%20%3Fitem2%20p%3AP217%20%3Finv2statement%20.%0A%20%20%3Finv2statement%20ps%3AP217%20%3Finv%20.%0A%20%20%3Finv2statement%20pq%3AP195%20%3Fcollection%20.%20%0A%20%20FILTER%28%3Fitem%21%3D%3Fitem2%29%0A%0A%20%20%7D%20LIMIT%20500%0A often time out.

if you unpack it in a bunch of unions it completes in less than a second: https://query.wikidata.org/#SELECT%20%3Fitem%20%3Fitem2%20%3Finv%20WHERE%20%7B%0A%7B%20%3Finv1statement%20pq%3AP195%20wd%3AQ28045665%20.%20%7D%20union%0A%7B%20%3Finv1statement%20pq%3AP195%20wd%3AQ28045660%20.%20%7D%20union%0A%7B%20%3Finv1statement%20pq%3AP195%20wd%3AQ28045674%20.%20%7D%20union%0A%7B%20%3Finv1statement%20pq%3AP195%20wd%3AQ2066737%20.%20%7D%20union%0A%7B%20%3Finv1statement%20pq%3AP195%20wd%3AQ18600731%20.%20%7D%0A%0A%20%20%3Fitem%20p%3AP217%20%3Finv1statement%20.%0A%20%20%3Finv1statement%20ps%3AP217%20%3Finv%20.%0A%0A%7B%20%3Finv2statement%20pq%3AP195%20wd%3AQ28045665%20.%20%7D%20union%0A%7B%20%3Finv2tatement%20pq%3AP195%20wd%3AQ28045660%20.%20%7D%20union%0A%7B%20%3Finv2statement%20pq%3AP195%20wd%3AQ28045674%20.%20%7D%20union%0A%7B%20%3Finv2statement%20pq%3AP195%20wd%3AQ2066737%20.%20%7D%20union%0A%7B%20%3Finv2statement%20pq%3AP195%20wd%3AQ18600731%20.%20%7D%0A%0A%20%20%3Fitem2%20p%3AP217%20%3Finv2statement%20.%0A%20%20%3Finv2statement%20ps%3AP217%20%3Finv%20.%0A%20%20FILTER%28%3Fitem%21%3D%3Fitem2%29%0A%0A%20%20%7D%20LIMIT%20500%0A%20


```
SELECT ?item ?item2 ?inv WHERE {
VALUES ?collection {wd:Q28045665 wd:Q28045660 wd:Q28045674 wd:Q2066737 wd:Q18600731 } . # The different collections
?item p:P217 ?inv1statement .
?inv1statement ps:P217 ?inv .
?inv1statement pq:P195 ?collection .
?item2 p:P217 ?inv2statement .
?inv2statement ps:P217 ?inv .
?inv2statement pq:P195 ?collection .
FILTER(?item!=?item2)

} LIMIT 500
```
often time out.

if you unpack it in a bunch of unions it completes in less than a second:

```
SELECT ?item ?item2 ?inv WHERE {
{ ?inv1statement pq:P195 wd:Q28045665 . } union
{ ?inv1statement pq:P195 wd:Q28045660 . } union
{ ?inv1statement pq:P195 wd:Q28045674 . } union
{ ?inv1statement pq:P195 wd:Q2066737 . } union
{ ?inv1statement pq:P195 wd:Q18600731 . }

?item p:P217 ?inv1statement .
?inv1statement ps:P217 ?inv .

{ ?inv2statement pq:P195 wd:Q28045665 . } union
{ ?inv2tatement pq:P195 wd:Q28045660 . } union
{ ?inv2statement pq:P195 wd:Q28045674 . } union
{ ?inv2statement pq:P195 wd:Q2066737 . } union
{ ?inv2statement pq:P195 wd:Q18600731 . }

?item2 p:P217 ?inv2statement .
?inv2statement ps:P217 ?inv .
FILTER(?item!=?item2)

} LIMIT 500
```


This is something the optimizer should handle. Optimizer output at https://query.wikidata.org/bigdata/namespace/wdq/sparql?explain&query=SELECT%20%3Fitem%20%3Fitem2%20%3Finv%20WHERE%20{%0A%20%20VALUES%20%3Fcollection%20{wd%3AQ28045665%20wd%3AQ28045660%20wd%3AQ28045674%20wd%3AQ2066737%20wd%3AQ18600731%20}%20.%20%23%20%20The%20different%20collections%0A%20%20%3Fitem%20p%3AP217%20%3Finv1statement%20.%0A%20%20%3Finv1statement%20ps%3AP217%20%3Finv%20.%0A%20%20%3Finv1statement%20pq%3AP195%20%3Fcollection%20.%20%0A%20%20%3Fitem2%20p%3AP217%20%3Finv2statement%20.%0A%20%20%3Finv2statement%20ps%3AP217%20%3Finv%20.%0A%20%20%3Finv2statement%20pq%3AP195%20%3Fcollection%20.%20%0A%20%20FILTER(%3Fitem!%3D%3Fitem2)%0A%0A%20%20}%20LIMIT%20500%0A

TASK DETAIL
https://phabricator.wikimedia.org/T154280

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Smalyshev
Cc: Esc3300, Smalyshev, Nikki, Aklapper, Multichill, EBjune, mschwarzer, Avner, debt, Gehel, D3r1ck01, Jonas, FloNight, Xmlizer, Izno, jkroll, Wikidata-bugs, Jdouglas, aude, Deskana, Manybubbles, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to