in reply to very huge mysql request

Rewrite your SQL statement so that it only returns the first row. Most likely this can be done by appending LIMIT 1 to your query. Otherwise, MySQL will do far more work than what is necessary. You want to make sure there is an ORDER BY ... clause in your SQL too, so your first row is a well-defined result.

Also consider instead of doing a loop which repeats the same query 100000 times with different parameters, combine that loop into one query which returns all 1000000 resultsets.