Lucas_Werkmeister_WMDE added a comment.

I tried to find out how many constraint checks we could save with this, specifically for the type constraint, which is the most expensive one out of the three where we can apply this optimization. This query, if I’m not mistaken, tells us that on Q42 (Douglas Adams),

  • “instance of human” is checked 19 times,
  • “instance of human or fictional character” and “instance of human, group of humans, fictional character, or character that may or may not be fictional” are each checked 7 times,
  • “instance of human, fictional character, or animal” is checked 4 times,
  • two other constraints are checked 3 times each,
  • and seven more constraints are checked 2 times each.

This means that a total of 44 out of 89 type checks are redundant (query). Let’s run those numbers for a few other items:

  • Q183 (Germany): 394 out of 429 type checks redundant.
  • Q23 (George Washington): 69 out of 111 type checks redundant.
  • Q9368300 (current popular item): 2 out of 13 type checks redundant.
  • Q21558717 (current item with most statements – source): 5103 out of 5107 type checks redundant.
  • Q62444 (random item): 13 out of 31 type checks redundant.
  • Q681946 (another random item): 2 out of 5 type checks redundant.

Note: the second query, which returns the number of redundant and total type checks, is pretty crazy, and there might be some error in it. I’ve tried to comment it extensively, so I hope that someone else can look over it and check if it’s correct :)

Overall, it seems like with this optimization, we might be able to save, very roughly speaking, about half of all type constraint checks we perform. (Note, however, that this doesn’t help the “value type” constraint, which is equally expensive and more common.)


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

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

To: Lucas_Werkmeister_WMDE
Cc: gerritbot, thiemowmde, Jonas, Lucas_Werkmeister_WMDE, Aklapper, Adrian1985, Cpaulf30, Lahi, Gq86, Baloch007, Darkminds3113, Lordiis, GoranSMilovanovic, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, QZanden, LawExplorer, Lewizho99, Maathavan, Agabi10, Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to