Page MenuHomePhabricator

performance: don't query for desiredUnits and serviceLinks at DataValue creation
Closed, ResolvedPublic

Description

Author: info

Description:
SMWDatValue->newAttributeValue() sets up desiredUnits and serviceLinks (and new
possibleValues if we implement enumeration). These may involve DB queries. It
seems it would be better to set these to null or false and only give them values
if and when their getDesiredUnits/ServiceLinks() methods are called.


Version: unspecified
Severity: minor

Details

Reference
bz8752

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:31 PM
bzimport set Reference to bz8752.

info wrote:

I have a local patch that fixes this. Without it, I verified that a simple
inline query like [[Climate:=+]] makes five GetSpecialPropertyValues queries for
the attribute Climate's special properties (HAS_TYPE, MAIN_DISPLAY_UNIT,
DISPLAY_UNIT, POSSIBLE_VALUES, and SERVICE_LINK).

With my patch, these queries go away. However, it's a potentially destabilizing
change so I'm going to run with it a while before committing it, or I can share
it with interested developers.

Note that each result in the inline query still makes a GetSpecialPropertyValues
query for SERVICE_LINK, because newAttributeValue() winds up calling the
datatype's processValue() which adds service links whether or not they're not
needed. processValue() needs to be refactored.

info wrote:

patch to SMW_DataValue.php

Patch works for me, not sure about service links.

Attached:

info wrote:

I checked in fixed SMW_DataValue.php to SVN. I filed bug 8961 about refactoring
processValue() to do less work.