-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search method takes more time when load 7k household list #2040
Comments
can you please add your search api call here as well? |
@mahmud6390 Is this based on the FHIRCore code? Refer to RegisterRepository#L91 to access the Search API code responsible for generating the query. |
@jingtang10 time consuming whenever we have added
|
` private fun filterFamily(search: Search) {
}` |
@jingtang10 We also shared some feedback on some of the query performance issues on FHIRCore. Refer to the latest comments on this issue for more info opensrp/fhircore#2066 |
@mahmud6390 I deleted your comment as it contained sensitive info. Just so we don't loose what was said, the DB size was 21MB |
I can replicate the issue on my machine and can confirm the query is slow. The issue seems to be from the double left join we do when create the search query here when the sort is done on a DateClientParam type. If we are able to remove one of the left joins, the query runs much faster, e.g.:
|
Actually, my previous analysis was wrong. The only reason the left join in the above query runs faster is that the I do have a fix though! Please see PR #2047 |
Adding the query plan from having the new index:
we can see it uses our new index to search for the |
and here is the query plan from having the existing slow way:
In the query plan for the faster query, the index used is Looking at the data in |
I pushed a new commit to the PR to further optimise the query plan:
with these new commit, we are |
after merge PR #2047 now it's working smoothly like 50sec to 2 sec per page or search |
Thanks @mahmud6390 , great to hear it works!! We will add the PR to our main branch after review |
Uploaded 7k household to FHIR server with basic info like name and id. After initial syncing done it's take more time to load at pagination or search by name. It take 2 minute to load all household at SDK.
Like a query below
SELECT a.serializedResource FROM ResourceEntity a LEFT JOIN DateIndexEntity b ON a.resourceType = b.resourceType AND a.resourceUuid = b.resourceUuid AND b.index_name = '_lastUpdated' LEFT JOIN DateTimeIndexEntity c ON a.resourceType = c.resourceType AND a.resourceUuid = c.resourceUuid AND c.index_name = '_lastUpdated' WHERE a.resourceType = 'Group' AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Group' AND index_name = 'active' AND index_value = 'true' ) AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Group' AND index_name = 'type' AND (index_value = 'person' AND IFNULL(index_system,'') = 'http://hl7.org/fhir/group-type') ) AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = 'Group' AND index_name = 'code' AND (index_value = '35359004' AND IFNULL(index_system,'') = 'https://www.snomed.org') ) ORDER BY b.index_from DESC, c.index_from DESC LIMIT 10 OFFSET 30
when using ORDER BY it's take 50 sec per page or getting search result after search by name.
Device configuration: samsung galaxy tab A 8 enc(SM-T295), ram 2 GB, rom 16 GB.
Would you like to work on the issue?
Yes, we want to work in this issue .We'll need to add order by with household added datetimewise, household serial number,lastvisited timewise. so how can we implement this any tips for this
The text was updated successfully, but these errors were encountered: