Fix #8434 (join by spatial location locks up QGIS)

By caching the features of the provider in the inner loop, there is
a considerable speedup (compared to doing millions of queries)