Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR aims to speed up typeahead queries for protein and gene names by switching to optimized materialized views.
- Updated protein name query to use predictions_uniprot_annot_mv02 with the protein_name_lower column.
- Updated gene name query to use predictions_uniprot_annot_mv03 with the gene_name_lower column.
Comments suppressed due to low confidence (1)
app/db/queries.py:171
- Verify that the MV tables (predictions_uniprot_annot_mv02 and predictions_uniprot_annot_mv03) are properly indexed on the lower-case columns to ensure optimal performance with the LIKE queries.
query = f"""SELECT DISTINCT gene_name FROM cleandb.predictions_uniprot_annot_mv03 WHERE gene_name_lower LIKE LOWER($1) ORDER BY 1 ASC"""
| # match any part of the string | ||
| search = '%' + search + '%' | ||
| query = f"""SELECT DISTINCT protein_name FROM cleandb.predictions_uniprot_annot WHERE LOWER(protein_name) LIKE LOWER($1) ORDER BY 1 ASC""" | ||
| query = f"""SELECT DISTINCT protein_name FROM cleandb.predictions_uniprot_annot_mv02 WHERE protein_name_lower LIKE LOWER($1) ORDER BY 1 ASC""" |
There was a problem hiding this comment.
Consider using an explicit column name in the ORDER BY clause (e.g., ORDER BY protein_name) instead of the column index to improve clarity and maintainability.
Suggested change
| query = f"""SELECT DISTINCT protein_name FROM cleandb.predictions_uniprot_annot_mv02 WHERE protein_name_lower LIKE LOWER($1) ORDER BY 1 ASC""" | |
| query = f"""SELECT DISTINCT protein_name FROM cleandb.predictions_uniprot_annot_mv02 WHERE protein_name_lower LIKE LOWER($1) ORDER BY protein_name ASC""" |
This file contains hidden or 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
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.
Thanks to @cs2018ncsa !