Tagged Variants grid search box optimisation: a search takes about 12 s with 200k tags
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- postgresql, python
- Domain
- databases, performance
Research direction
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.
Written by the indexing model from the issue text.
Description
🤖 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:
- 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.
- Coordinate: when the text parses as a coordinate (
VariantCoordinate), look the variant up directly. - Tag, user, analysis, sample, patient: match in their own small tables.
- 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.
- Dominant language
- Python
- Stars
- 31
- Forks
- 4
- Avg merge
- 4h 52m
- Merged PRs (30d)
- 183
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SACGF/variantgrid
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
SACGF/variantgrid#2964 · 1 comment ·
Maintainers usually reply within 1 day
-
Genome build now duplicated in "imported as" on allele pagePossibly taken @TheMadBug claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
SACGF/variantgrid#2950 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
SACGF/variantgrid#2865 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SACGF/variantgrid#2647 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
SACGF/variantgrid#2341 · 3 comments ·
Maintainers usually reply within 1 day
All issues in SACGF/variantgrid
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day