Page MenuHomePhabricator

Property filter to reduce computing time of mw.wikibase.getEntity()
Open, LowestPublic

Description

mw.wikibase.getEntity() is an expensive function which can be called several hundreds times in an article. The computing time is huge if an entity owns many properties. In most cases only a reduced properties set is used. I propose to use an additional and optional table parameter with the properties in need to reduce both computing time and memory usage.

Example:

  • now: mw.wikibase.getEntity( 'Q183' )
  • maybe in future mw.wikibase.getEntity( 'Q183', { 'P36', 'P37', 'P38', 'P1082', 'P1813' } )

In Wikivoyage/de articles mw.wikibase.getEntity() can be called up to 200 times per article. With an average access time of 20 ms, so it takes about 4 s computing time in total.

But there are application in other projects like Wikicite-Wikidata calls, too.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 3 2017, 6:46 AM
thiemowmde triaged this task as Lowest priority.Dec 11 2017, 9:36 AM

We are currently collection ideas (including this one) in T182147: more convenience functions for Lua.

If this ticket is exclusively about performance – and from what I read in the tickets description it is – then I believe this is better solved with T76156: [Story] mw.wikibase: Use __index to lazy load entity contents. This is why I triage this suggestion as "lowest" for now. If this is also about a user-facing use-case (some repeating Lua coding task you wish you had a convenience function for) then please expand the tickets description accordingly.

hoo moved this task from Incoming to To do later on the Wikibase-Lua board.Apr 12 2018, 1:56 PM
Uzume added a subscriber: Uzume.Apr 17 2018, 1:05 PM

Perhaps this ticket is old but it seems to me we already have such filters with mw.wikibase.getBestStatements and mw.wikibase.getAllStatements. Of course those do not pull multiple properties in a single execution but they do filter to a single property without pulling the expensive complete set/tree of property data. One could easily create a function to execute one of these multiple times and combined the results to get what is requested in this ticket.