-
Notifications
You must be signed in to change notification settings - Fork 296
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
Engine: Add an API to allow adding database indexes #1944
Comments
@jingtang10 Kindly review this and get back in case you have any questions or suggestions |
@aditya-07 Can you please add this issue to Android Fhir Sdk project? |
@ekigamba can you share some exampel queries? Is An alternative solution could be, if Also, does this work #1778 allow you to add a custom search param (which we'll use in indexing)? @aditya-07 FYI. |
@jingtang10 So far this is the query that we used on p2p
I believe this is one use-case where adding a database index will speed up queries and it would mean that there might be other areas where individual implementers might get value from this On the custom search param, the FHIR Resource properties that we filter by are already defined FHIR search parameter |
@ekigamba Can you share the raw query that you use in P2P sync ? |
Here is the query
The query plan doesn't seem to change for this specific query but based on the idea that sorting uses indexes. The query plan changes for the query below
Here is the first query in action |
Is your feature request related to a problem? Please describe.
Some FHIR Engine search queries, performed on the local database, become slow when there's a lot of data. An example is a query that needs to sort data by chronological order before returning the first X from offset Y and there are 8,000 records matching the query.
The search param tables have indexes formed from multiple columns which allows for faster filtering during search but have as much impact where only one field is used such as a sort.
Describe the solution you'd like
An API that allows adding a database index. This can be considered as a migration so that it's only run once and before the database is loaded. I'm open to suggestions on the design of this API
Describe alternatives you've considered
The team has tried rewriting some of the queries to better use the indexes in the filters and sort by multiple field/columns declared as indexes. This did not provide the performance improvements The bottle neck is sorting the records and this is needed before paging the results. Performing this operation at the database level is more efficient in terms of time and space.
Additional context
_lastUpdated
. Some of these resource types have grown in numbers and queries to fetch this data have slowed down. An example is theDateTimeIndexEntity
table which stores the_lastUpdated
The text was updated successfully, but these errors were encountered: