The approach by chunk would make the code more complex and still slow. I think the main issue here was the number of IssueLink returned by the JOIN. On my DB 10 hashes may return thousands of links.
I added a filter by revision/diff for existing issues. The estimated cost in pgadmin dropped from max 49265.77 to max 91.8 on my database. I also added an iterator() to be sure we avoid a memory issue there.
Closes #2516
The approach by chunk would make the code more complex and still slow. I think the main issue here was the number of IssueLink returned by the JOIN. On my DB 10 hashes may return thousands of links.
I added a filter by revision/diff for existing issues. The estimated cost in pgadmin dropped from max
49265.77
to max91.8
on my database. I also added an iterator() to be sure we avoid a memory issue there.