Skip to content
Commit 15e95b2f authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Optimize queries in FetchHelper

Instead of JOINing Flag/MimeType/PartType tables to the queries just to resolve
the entity name, we use the fact that those entities are available in the local
in-memory cache and that we can resolve them quickly via T::retrieveById(). The
cost of looking up the entries in the hastable is smaller than the cost of DB
having to calculate the JOIN on potentially large tables (like JOINing to
PimItemFlagRelation or even PartTable).

This reduces the cost of these queries notably, especially when retrieving large
amount of items.

We use local QHash tables instead of using T::retrieveById() directly, because
we need to do in avarage up to 4 lookups per item, and storing the end data
in the hash table plus the fact that most of the hash table can be inlined
makes a measurable difference compared to just using T::retrieveById().name()
all the time.

As a side-effect this is also more memory efficient since all the names are
shared, instead of the database having to allocate new string for each row.

See T628 on Phabricator for more details and measurements.
parent bd75d63a
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment