This PR is from the dojo between me and @jaguillette(thanks to Jeremy for cracking the code/django docs on this) which reduces the number of database queries that PartialMatchFormLookupAPI makes. Fixes #507
The endpoint has been refactored to filter/distinct/order_by(rank) on the Lemma model based on the forms__form parameter via the reverse relation from the FormToLemma model through the related_name attribute.
prefetch_related has been implemented to retrieve the glosses associated with each of the lemma which drastically reduces the number of queries from over 9000 to 1
This PR is from the dojo between me and @jaguillette(thanks to Jeremy for cracking the code/django docs on this) which reduces the number of database queries that
PartialMatchFormLookupAPI
makes. Fixes #507filter
/distinct
/order_by
(rank) on theLemma
model based on theforms__form
parameter via the reverse relation from theFormToLemma
model through therelated_name
attribute.prefetch_related
has been implemented to retrieve theglosses
associated with each of the lemma which drastically reduces the number of queries from over9000
to1