Interpolating Data in Influx

Hello! I have a list of times and i need to return an interpolated point for each time. the list can be as long as needed, there are no limits on how many times a user can pass in. there are also no limits saying the times need to be evenly spaced, they could be completely random intervals. I currently have two methods of doing this in flux, however there are issues with both. I was wondering if anyone had any ideas for how to speed this up.

1st method is returning ALL of the data within the smallest/largest time in the list, then sorting throught the data and interpolating on the client. this works pretty well if the timespan is only about a day or so. when you start getting into doing this for over a weeks worth of data, returning every data point for a week starts to get pretty slow however.

2nd method is querying for ONLY the prev and next value to each timestamp im looking for. so lets say i had a list of 100 times, i would have to query 200 times, 100 times for each prev point i need and 100 times for each next point i need (i do combine these with unions so im not actually sending 200 queries). this method works really well if the list of times is short, and it also doesnt matter how spread out the times are since it isnt querying the entire timespan. you can go back 3 years from now grab a few points, then go back a day and grab more points without having to return all 3 years worth of data. but when you give this method a few thousand times to query, it starts to bog down even worse than the 1st method.

so i guess my question is … is there an easy way to give flux a list of times (unevenly spaced) and get the prev and next points back that way i can run an interpolation method in the client on ONLY the points i need?