Skip to content
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

No need to read full resource during updates #2417

Open
punktilious opened this issue May 24, 2021 · 2 comments
Open

No need to read full resource during updates #2417

punktilious opened this issue May 24, 2021 · 2 comments
Labels
P3 Priority 3 - Nice To Have performance performance schema-change a schema change

Comments

@punktilious
Copy link
Collaborator

punktilious commented May 24, 2021

For an update, the REST layer first reads the current existing resource to obtain the latest version number. This is expensive because the full resource is retrieved and parsed.

Only the metadata is required, which can now be achieved by a simple select from xx_logical_resources.

This will improve performance in two ways:

  1. Less CPU required on the FHIR server to decompress and parse the resource payload
  2. Only need to access the xx_logical_resources row which is much "thinner" and more likely to be cached than reading the data blob from xx_resources.

To implement this properly, we may want to consider storing the resource fingerprint (hash) in the xx_logical_resources table too. This is required so that we can compare the inbound resource with an existing resource, and skip the update if requested.

A similar fingerprint value could be stored to detect parameter changes, which could significantly improve reindex performance.

@lmsurpre
Copy link
Member

While discussing with Robin we realized that including the full contents of the previous resource is currently part of our contract for both audit logging and for the persistence event (used by persistence interceptors and therefor our notification mechanism as well). It would be hard to remove that and not break folks.

@lmsurpre
Copy link
Member

If we did this we'd want to do this BEFORE invoking beforeUpdate method on interceptors. More of a "short-circuit" path.

@lmsurpre lmsurpre added P3 Priority 3 - Nice To Have schema-change a schema change labels Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Priority 3 - Nice To Have performance performance schema-change a schema change
Projects
None yet
Development

No branches or pull requests

2 participants