Skip to content

[WV-2296]queryset_find_candidates_to_link_to_this_politician inefficient query queryset[Team Review]#3057

Open
pravingv wants to merge 12 commits intowevote:developfrom
pravingv:WV_2296_queryset
Open

[WV-2296]queryset_find_candidates_to_link_to_this_politician inefficient query queryset[Team Review]#3057
pravingv wants to merge 12 commits intowevote:developfrom
pravingv:WV_2296_queryset

Conversation

@pravingv
Copy link
Copy Markdown
Contributor

@pravingv pravingv commented Mar 22, 2026

What github.com/wevote server/issues does this fix
WV-2296 'queryset_find_candidates_to_link_to_this_politician` inefficient query queryset

Changes included this pull request?
politician/controllers.py
Added trigram-based query support to improve SQL query performance. If trigram indexes are unavailable, the original query is used as a fallback so results are still returned.

politician/enums.py politician/views_admin.py
Added a new enum, RET_CANDIDATES_MATCH, with the label "Find possible Candidate duplicates of this politician". This helps separate speed statistics for duplicate-politician queries from candidate-match queries for a politician.

**Note: **This PR should be reviewed and executed together with the following PRs:
#3055
— Needed to show trigram vs. non-trigram search results.
#3054
— Generates the required trigram indexes for improved SQL query performance.

politician_url5 = request.GET.get('politician_url5', False)
political_party = request.GET.get('political_party', False)
state_code = request.GET.get('state_code', False)
use_trigram_match = positive_value_exists(request.GET.get('use_trigram_match', False))
Copy link
Copy Markdown
Contributor

@mjacquot1 mjacquot1 Apr 6, 2026

Choose a reason for hiding this comment

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

This is a nitpick, but I would recommend:
trigram_match = request.GET.get('use_trigram_match', False)

and later on use_trigram_match = positive_value_exists(trigram_match)

This is just to keep logic blocks consistent since the rest of them are request.GET.get() clustered

@mjacquot1
Copy link
Copy Markdown
Contributor

Seems good overall!

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