Page MenuHomePhabricator

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


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.


  • 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

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.

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.