The phrase you are looking for is "asynchronous execution". Parts of PHP support async operations, most of it doesn't, and the parts that do won't function exactly the same on every host.
It is in your user's best interest to not throw arbitrary delays into code. PHP also has an execution time limit when running on a web host. When PHP runs from the command-line (e.g. via a cron job), there generally is no time limit. This seems like one of those things best left to a long-running cron script to process. Write a temporary file that indicates that the cron script needs to check the database. The cron script checks for that file's existence every second (PHP has some nuisance issues here - see clearstatcache()) - if so, it runs the SQL query looking for what needs processing, does the processing, and then updates the database to indicate that it is done. Of course, you said there is an XML file that is generated, so you can just check to see if it exists at that point.