Found this while waiting for the CSV export of a search result from (*undisclosed project*) ...
The export took almost half an hour even though it was just extracting the snail mail addresses of about 40K contacts, so what caused it to only spit out about 20 rows per second? Looking at the PROCESSLIST output a pattern was easy to detect. What greeted me was a single running query which had only been running for a few seconds even though i was already waiting for export results for about 20 minutes:
SELECT ... LIMIT 32900, 100;
And then a few seconds later:
SELECT ... LIMIT 33000, 100;
So instead of retrieving the search results for export by firing a single query and processing the results in one go the same pagination logic seemed to be used as for displaying search results. About 400 queries instead of a single one, and each iteration taking more query time, with finally the last one taking about the same time as the only query in the all-at-once alone.
Somewhere, somehow, something terribly went wrong it seems ....