How to properly send many mysql queries via php and what happens with ajax requests after they are sent?

There is typically a hosting limit to how long PHP can run, on shared this can be as low as 60-90 seconds. Since WP’s Ajax is just another instance of PHP load it will likely be subject to that restriction.

Even if it’s disabled any error risks knocking such a long running process out.

Unfortunately there isn’t really any mechanism in WP for running long tasks. You might want to look for other PHP solutions for it.

The closest WP option would be to use WP cron to toggle task periodically, which will grab smaller share, process it, and track progress.