It seems like this was accurate - swapping the order of the == and != yielded much better performance. I was able to further improve it by chunking on country which is also indexed, and have got it running ~500x faster at this point, which is good enough for an infrequent task.
Thanks all - appreciate this ended up not being an Ecto issue and more of a general database problem, but I’ve learned a lot about how Ecto works from this too.






















