How we implemented find-on-page with infinite scroll
blog.streak.com
blog.streak.com
Streak, thanks for sharing all your clever technical hacks, I always enjoy reading them.
Also, presumably it isn't always identical to the browser search box - you're going to have trouble with all combinations of browsers and colour schemes and skins etc.
All that aside in my opinion the mistake is to allow the user to have »hundreds of thousands of rows« on the screen - real or virtual - in the first place. What a waste of time to scroll through that. I would just offer filters that almost immediately update the set of matching rows and display the first few and maybe highlight the match in each row. When the user scrolls to the bottom you can load more rows either automatically or by pressing a button.
The user will understand what is going on, is encouraged to filter instead of randomly scrolling through thousands of rows and everything from in-page search to printing works just as expected. And last but not least it is probably much simpler than your solution. (And the user is still able to scroll through all rows and in almost all cases they will stop way before the page size becomes a problem for the browser besides you are using an old phone, but whoever attempts to scroll through thousands of rows on a phone probably deserves the result.)
What warranted this extra load onto your database instances, as opposed to loading all rows on the client? Do they usually have a million tasks?