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

Token contains search query causes table scan #3789

Open
mattwiller opened this issue Jan 23, 2024 · 0 comments
Open

Token contains search query causes table scan #3789

mattwiller opened this issue Jan 23, 2024 · 0 comments
Labels
search Features and fixes related to search

Comments

@mattwiller
Copy link
Member

mattwiller commented Jan 23, 2024

The server currently inadvertently supports non-FHIR-standard use of the :contains search modifier with token search parameters (i.e. those used for coded values), allowing users to search on just part of the code. However, this query is very expensive: it generally causes a full table scan and performs wildcard matching on each row (i.e. value LIKE 'code%'). On large lookup tables, especially those for common resource types like Observation_Token, this query is prohibitively slow.

Since :contains is not specified to work with token search parameters, which by nature should generally be matched exactly, I believe that this code path should be removed.

As part of this work, we should also verify that the lookup table is handling all four cases of the token syntax correctly:

  • [parameter]=[code]: the value of [code] matches a Coding.code or Identifier.value irrespective of the value of the system property
  • [parameter]=[system]|[code]: the value of [code] matches a Coding.code or Identifier.value, and the value of [system] matches the system property of the Identifier or Coding
  • [parameter]=|[code]: the value of [code] matches a Coding.code or Identifier.value, and the Coding/Identifier has no system property
  • [parameter]=[system]|: any element where the value of [system] matches the system property of the Identifier or Coding
@mattwiller mattwiller added the search Features and fixes related to search label Jan 23, 2024
@rahul1 rahul1 added this to the Milestone Quality milestone Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
search Features and fixes related to search
Projects
Status: No status
Development

No branches or pull requests

2 participants