Hi,
Based on your current memory setup try to slice the data , like put filter on dates and execute the program.
SQL Varaints are data types like VARCHAR(), INTEGER , which you can replace based on your input data .
To tune query and perform optimization require excessive analysis.
Br, Vaibhav