Advice
As always it is said, there is no need for you to fetch this much data, where are you going to present that much data? Suppose, for instance, you got all that data. How are you going to present it to the user? That would take a lot of time again, most of the users don't have fast computer systems like the development teams have. So there is a chance that the user has to experience a bad UX (User Experience).
It will be better for you to load thousand-th part of this data, ~200 records at a time, and then display them, if user wants more records, fetch next ones.
This way, your problem will be minimized, and your user won't have to face time dilation and other problems too.
Solution
Since you're here for a solution, so here is one. Increase the amount of RAM and CPU on your system, and add the feature of caching. Facebook and other giants use this feature to make sure that their service is fast and the users don't have to wait for their response (HTTP response; not user oriented responses).
https://en.wikipedia.org/wiki/Cache_(computing)[
^]
Read above Wikipedia article to learn more about Caching.
So, the only way of letting this thing happen, is to increase the RAM, CPU and making sure all of the processes are done and caches, so that as soon as the user requests for data. Response from the cache is picked up and transferred to the stream, so that he can easily read the data without having to wait.
Note: As already mentioned, rendering of the output also takes time. So this also doesn't fit as the best possible way. There isn't any best solution.