-
Notifications
You must be signed in to change notification settings - Fork 329
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
Fix lookup table tsv indexes #3841
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
reshmakh
approved these changes
Jan 29, 2024
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Merged
medplumbot
added a commit
that referenced
this pull request
Jan 31, 2024
Fixes #3794 - MeasureReport.period search (#3850) Extra check for vmcontext bots (#3863) Add and use vite-plugin-turbosnap (#3849) Downgrade chromatic (#3848) Repo sql fixes for cockroachdb (#3844) Remove Health Gorilla from medplum-demo-bots (#3845) fix-3815 cache presigned s3 binary urls (#3834) Use tsvector index for token text search (#3791) rate limit should return `OperationOutcome` (#3843) Add global var "module" to vm context bots (#3842) Fix lookup table tsv indexes (#3841) Always use estimate count first (#3840) Disambiguate getClient (#3839) Fix invalid mermaid graph in diagnostic catalog docs (#3836) fix-3809 race condition in Subscription extension fhir-path-criteria-expression %previous value lookup (#3810) Fix Sonar code smells: mark React props readonly (#3832) RDS proxy (#3827) Fixed lookup tables in migration generator (#3830) Fixed deprecated jest matchers (#3831) Update README.md (#3828) Update fhir-basics.md (#3829) Case study content and images (#3820) Added rdsReaderInstanceType and RDS upgrade docs (#3826) Dependency upgrades (#3825) Separate search popup menus for 'text' and 'token' (#3824) Improve performance of token sort (#3823) Additional logging (#3790) Fix calendar input button style (#3817) Don't add _total default in SearchControl (#3818) Dark mode (#3814) Fixes #3812 - FHIR profile cache bug (#3813) Document using medplum client to integrate with external FHIR servers (#3811) Use specific advisory locks (#3805) Nested transactions (#3788) Fix signin page on graphiql (#3802) fix(heartbeat): start heartbeat on first bind to sub (#3793) Fix async job tests (#3795) Document using vm context bots (#3784) Refactored access policy docs based on customer feedback (#3785) Support Redis TLS config from Env (#3787) feat(subscriptions): add `heartbeat` for WS subs (#3740) Update Bot metrics (#3763)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 31, 2024
Fixes #3794 - MeasureReport.period search (#3850) Extra check for vmcontext bots (#3863) Add and use vite-plugin-turbosnap (#3849) Downgrade chromatic (#3848) Repo sql fixes for cockroachdb (#3844) Remove Health Gorilla from medplum-demo-bots (#3845) fix-3815 cache presigned s3 binary urls (#3834) Use tsvector index for token text search (#3791) rate limit should return `OperationOutcome` (#3843) Add global var "module" to vm context bots (#3842) Fix lookup table tsv indexes (#3841) Always use estimate count first (#3840) Disambiguate getClient (#3839) Fix invalid mermaid graph in diagnostic catalog docs (#3836) fix-3809 race condition in Subscription extension fhir-path-criteria-expression %previous value lookup (#3810) Fix Sonar code smells: mark React props readonly (#3832) RDS proxy (#3827) Fixed lookup tables in migration generator (#3830) Fixed deprecated jest matchers (#3831) Update README.md (#3828) Update fhir-basics.md (#3829) Case study content and images (#3820) Added rdsReaderInstanceType and RDS upgrade docs (#3826) Dependency upgrades (#3825) Separate search popup menus for 'text' and 'token' (#3824) Improve performance of token sort (#3823) Additional logging (#3790) Fix calendar input button style (#3817) Don't add _total default in SearchControl (#3818) Dark mode (#3814) Fixes #3812 - FHIR profile cache bug (#3813) Document using medplum client to integrate with external FHIR servers (#3811) Use specific advisory locks (#3805) Nested transactions (#3788) Fix signin page on graphiql (#3802) fix(heartbeat): start heartbeat on first bind to sub (#3793) Fix async job tests (#3795) Document using vm context bots (#3784) Refactored access policy docs based on customer feedback (#3785) Support Redis TLS config from Env (#3787) feat(subscriptions): add `heartbeat` for WS subs (#3740) Update Bot metrics (#3763)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing issue in previous migration that failed to create indexes on tsvectors.
ChatGPT analysis of resulting queries:
The
EXPLAIN
output shows the execution plan for your SQL query. This query is selecting records from the"Patient"
table where certain conditions are met, and there exists at least one matching record in the"Address"
table. Let's break down the key components of this execution plan:Limit: The query starts with a
LIMIT 21
, which means it will only retrieve the first 21 records after sorting.Sort: Before limiting the results, it sorts the data based on
"Patient"."lastUpdated"
in descending order. Sorting operations can be computationally expensive, especially if the dataset is large.Nested Loop: The query uses a nested loop join to combine records from
"Patient"
and"Address"
tables. This method is generally efficient for queries where one of the tables returns a small set of rows.HashAggregate: This step is part of processing the
EXISTS
subquery. It aggregates the results from the"Address"
table, grouping by"resourceId"
. This ensures that duplicate"resourceId"
values from the"Address"
table are consolidated.Bitmap Heap Scan on "Address": The plan scans the
"Address"
table using a bitmap heap scan, which is efficient for queries that retrieve a moderate number of rows. It's filtering based on the text search condition (to_tsvector('simple',"Address"."state") @@ to_tsquery('simple','CA:*')
).Bitmap Index Scan on "Address_state_idx_tsv": This indicates that the query is using an index specifically designed for full-text search on the
"state"
column of the"Address"
table. This helps in efficiently finding rows that match the text search criteria.Index Scan using "Patient_pkey": After identifying the relevant
"resourceId"
values from the"Address"
table, the query then performs an index scan on the"Patient"
table using its primary key. The conditions in theWHERE
clause are applied to filter the results.Performance Insights
Index Utilization: The query efficiently utilizes indexes, specifically a full-text search index on
"Address"."state"
and a primary key index on"Patient"
.Sorting Overhead: Sorting the results by
"Patient"."lastUpdated"
could be expensive, especially if this column is not indexed. Consider adding an index on"Patient"."lastUpdated"
if the performance is not optimal.Nested Loop Efficiency: The nested loop join is efficient in this context because the
EXISTS
subquery likely limits the number of rows that need to be joined.Cost Estimates: The cost estimates (
2411.21..2411.26
for the limit and2411.21..2411.81
for the sort) indicate that the database expects the operation to be reasonably efficient, given the conditions and data size.Full-Text Search: The use of full-text search (
to_tsvector
andto_tsquery
) suggests that the query might be sensitive to how the text data is indexed and stored.Overall, the query seems well-optimized, especially with the use of appropriate indexes. However, actual performance should be tested with real data, as execution plans can vary based on data size, distribution, and database configuration.