There is a 1/1000 chance that raw_search is broken for more than a thousand records. We shall soon see. Exciting.
Tweak the chunk size, it may be causing timeouts on very fat records