I'm trying to query search terms for a period of one year (approx. 2M search terms).
Using searchstream the request is relatively fast, but the memory goes way too high. (almost 9 gigabytes)
Here is a memory snapshot:

As you can see "Campaign " uses almost 700mb for the campaign names and resource names, here are the fields I use :
Other alternative would be using search and paginate the results (at each page I map to my custom object, so I can work with smaller objects, less memory needed). But the API response time for each page it's too slow (0.8 minutes per page if I set page_size to 10 000 it's 200 pages for 2M results so 0.8m * 200 = 2,6 Hours ).
Here is an example :
In other words, searchstream uses too many memory and search it's too slow.
What could be a solution that don't take too long / don't explode the memory?
I'm I missing another way to query?
Thank you