Open LZRS opened 1 week ago
do you have any performance benchmark numbers for this one or is this more speculative?
Yeah, it's kinda of speculative but I can get some data
For the above queries, with db
SELECT COUNT(*) FROM TokenIndexEntity;
74942 rows
SELECT COUNT(*) FROM TokenIndexEntity WHERE resourceType = 'Location';
11784 rows
SELECT COUNT(*) FROM ResourceEntity;
8881 rows
SELECT COUNT(*) FROM ResourceEntity WHERE resourceType = 'Location';
1966 rows
The first query took around17ms
and the second one 7ms
Additional context
SELECT COUNT(*) FROM (SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Location' AND index_name = 'status' AND index_value = 'active' INTERSECT SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Location' AND index_name = 'type' AND (index_value = 'bu' AND IFNULL(index_system, '') = 'http://terminology.hl7.org/CodeSystem/location-physical-type'));
57 rows
SELECT COUNT(*) FROM (SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Location' AND index_name = 'status' AND index_value = 'active' UNION ALL SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Location' AND index_name = 'type' AND (index_value = 'bu' AND IFNULL(index_system, '') = 'http://terminology.hl7.org/CodeSystem/location-physical-type'));
2023 rows
A suggestion to use
Intersect
orUnion
of the resultingresourceUuid
of the index table subqueries depending on theSearch
operation. This might help reduce redundancy if sameresourceUuid
appears across the tables or in the case of operationAND
,resourceUuid
doesn't appear.Example Query generated for multiple filters currently uses multiple ANDs across the different index tables
An example to currently generated query
May be replaced with