Optimize search indexing for review requests.
Review Request #13388 — Created Oct. 30, 2023 and submitted
The indexing queryset for review requests was hitting the same issue we
saw with datagrids and the API where aSELECT COUNT(*)
would end up
performing a very expensive nested query, due to the usage of
DISTINCT
. We have plans to removeDISTINCT
after some further
testing, but probably not until Review Board 7.However, we can now turn it off, if we don't mind the chance of
duplicates. That is fine for search indexing, since any duplicates will
just collapse into one entry.This change turns off distinct queries when indexing, and also adds
anotherprefetch_related
relation to pre-fetch diffsets. This reduces
the overall number of queries when indexing a batch of review requests.
Unit tests pass.
Tested building a full search index and inspecting all the generated
SQL queries, making sure we were performing simple queries and avoiding
excess queries.
Summary | ID |
---|---|
3c2b9adb8f7382f3c7516ce375170adf41495e3d |