20k visit/day, performance issue

Hello guys.

I have a site, with 20k visit daily. A use Auto-Archiving from cron, and i set browser_archiving_disabled_enforce = 1 already, for better performance. I increased PHP memory limit to 4G.

I set a custom variable for every visit, but i have some problem to get back them.

First i tried to get back costum variables back with this api call ( i use Live.getLastVisitsDetails)

mysite/index.php?module=API&method=Live.getLastVisitsDetails&idSite=3&period=day&date=today&format=JSON&token_auth=123&flat=1&showColumns=customVariableName1,customVariableValue1&filter_limit=-1

It works for one day, but it’s still very slow, and if i change period=range and i give 2-3 month, it takes forever and cloudflare gives back 504 gateway timeout. It is normal? I mean if i use auto archive, and i dont archive on the fly, shouldn’t be much faster? Or Live api calls are not archived, it’s just give back data from log_visit table?

After some research i found CustomVariables.getCustomVariablesValuesFromNameId Api call, and i figured out the limitations. ( After the top 500 or top 1000 rows, Piwik automatically groups pages, keywords, websites, etc. under the label "Others"; How do I force Piwik to not limit the data? - Analytics Platform - Piwik) How can i change the value to give back all of the customValues with no limitation?

And my last question, is it the right way? Do you have any idea how to get all of the CustomVariableValues with good performance?