Tagged Variants grid search box optimisation: a search takes about 12 s with 200k tags

Aperta
#2,885 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, python

Direzione di ricerca

Start with snpdb/views/datatable_view.py and variantopedia/grids.py, then inspect how DatatableConfig.power_search builds filters for VariantTagsColumns. Compare the current search plan with the proposed key lookup for annotations, coordinates, and related tables, including tags lifted from other builds. Measure the full search and count path on the 200k-tag dataset; done means searches approach the unsearched grid cost while preserving the documented matching behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🤖 Written by Claude

On Variants → Tagged Variants, searching in the Tags grid's Search box takes about 12 s on a database with 200k tags (vg-test2, GRCh37, lab user). The grid's other actions take about 5 s once #2878 / PR #2879 lands. A search for "GATA2", which matches 5 tags, takes 12.1 s on the PR.

What the search box matches

The text is matched case-insensitively as "contains" against every searchable column, ORed together:

  • Variant (coordinate string), Gene, g.HGVS (hidden)
  • Tag, Analysis id and name, Sample name, Patient identity, username and full name
  • Tag ID, Variant ID and the created date, each cast to text

snpdb/views/datatable_view.py:DatatableConfig.power_search does this for every grid. The Tags grid is variantopedia/grids.py:VariantTagsColumns.

Where the time goes

Each search runs the filter twice, once for the count and once for the page, at about 6 s each. Variant and Gene are computed for each tag through the build's variant, annotation and gene joins, so Postgres computes them for every tag before it can filter.

Each column searched on its own (2.8 s of each figure is the grid with no search):

Column Time
Gene 5.1 s
Variant 3.5 s
g.HGVS 2.7 s
Patient 2.1 s
Each of the rest under 1 s
All together, as the grid does it 6.2 s

Matching the same text against the annotation's gene symbol directly, for tagged variants only, takes 0.09 s.

Proposed approach

Resolve the search text to keys first, then filter tags on indexed columns:

  1. Gene symbol and g.HGVS: match against the build's annotation partition for tagged variants, going through the tag's allele as well as its variant. The grid also shows tags lifted over from other builds: the direct SQL above found 4 tags where the grid finds 5.
  2. Coordinate: when the text parses as a coordinate (VariantCoordinate), look the variant up directly.
  3. Tag, user, analysis, sample, patient: match in their own small tables.
  4. Filter: keep tags whose variant, allele or foreign keys are in those sets.

Numbers as text

The ID and created-date columns match by casting to text. Typing 12 matches every tag whose ID, variant ID or created date contains "12". Those columns could match only when the text is a whole number, and then by equality.

Expected outcome

A search should take close to the grid's unsearched cost (about 3 s after #2878), not 12 s. Not yet built or measured end to end.

Lingua principale
Python
Stelle
31
Fork
4
Merge medio
4h 52m
PR unite (30g)
183

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SACGF/variantgrid

Tutte le issue di SACGF/variantgrid

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.