Skip to content

Resolve "Long queries in frequency filter prevent analysis from loading"

Description

For some analyses, the query used to create the frequency filter takes around 30 seconds instead of a fraction of a second. The gunicorn workers timeout before the query is returned, preventing the analysis from being loaded.

The root cause of the longer query time is unknown, but appears to be deep postgres magic optimizing the query in the wrong way. This magic can be bypassed by resolving one of the filter clauses before the others.

The slow query happens when setting ad_gene_allele_ids, based on the filters in ad_filters. By resolving ad_hgnc_ids rather than leaving it as a subquery of one of the filters, the slow queries are eliminated.

Related issues

#220 (closed)

Notes to review (code/docs/QA)

Tests

General

  • Tests have been added that prove my fix is effective or that my feature works
  • Related tests have been modified/removed

Hypothesis testing:

  • Soak testing has been done
  • Distribution between positive / negative cases has been checked

Database

  • Includes changes to database schema
  • Includes necessary database migrations

Configuration

  • Includes changes to configuration
  • Includes configuration migration instructions in documentation

Merge checklist

  • Self-review of code has been performed.
  • Feature review and validation against specification has been performed (if applicable). Apply label: QAdone
  • Need for documentation has been evaluated and, if necessary, updated. Apply label: docsdone
  • Code and implementation has been reviewed by other core developer (including any changes based on initial review). Apply label: code reviewdone

Closes #220 (closed)

Edited by Tor Solli-Nowlan

Merge request reports

Loading