Skip to content

Conversation

@matthewberry
Copy link
Contributor

Thanks to @cs2018ncsa !

@matthewberry matthewberry requested a review from Copilot June 30, 2025 20:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"""
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"""

Copilot uses AI. Check for mistakes.
@matthewberry matthewberry merged commit 0003c79 into main Jun 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants