In EntityUsageTable::getUsedEntityIdStrings, we currently use a bulk query to see which Entity ID from a given set are actually present in the wbc_entity_usage table:
SELECT DISTINCT eu_entity_id FROM `wbc_entity_usage` WHERE eu_entity_id IN ('Q148475', 'Q54919', 'Q423048', 'Q2494649', 'Q13219454', 'Q131454', 'Q36578', 'Q1798125', 'Q2597810', 'Q19938912', 'Q193563', 'Q2553334', 'Q477675', 'Q623578', 'Q19675', 'Q13481868', 'Q384602')
This can lead to extremely slow queries and high resource consumption in some cases, as described in T116404#2370849.
We should instead use individual selects with LIMIT 1 for each ID:
SELECT eu_entity_id FROM wbc_entity_usage WHERE eu_entity_id = 'Q623578' LIMIT 1;
@jcrespo suggest that this is the better approach in T116404#2371094.