I am a new InfluxDB user and I need some advice on how to correctly use Continuous Queries for downsampling. If I understood the documentation correctly, a Continuous Query to group data by an interval i will be executed on data with timestamps in a range [now()-i, now()]. That means that if I insert data with timestamps older than now()-i, it won’t be concerned by the CQ.
I understand that normally CQ are used to save disk space by copying new data in databases with longer Retention Policies and a lower level of detail. I don’t want to use it that way. I am using downsampled databases to make queries on a large time ranges faster and the main database (the one with the non downsampled data) for queries on smaller time ranges. I will also have to insert data with old timestamps from CSV files in the database I am building. That means that I need the CQ to covers the full database.
I have two ideas :
1- run a SELECT … INTO … FROM … GROUP BY … query after importing a CSV file.
2- make a CQ with the EVERY and FOR keywords like :
CREATE CONTINUOUS QUERY <cq_name> ON <database_name> RESAMPLE EVERY <interval1> FOR <interval2> BEGIN <cq_query> END
This should run the query every EVERY intervals on data with timestamps between now()-FOR and now(). So my idea is to make the FOR interval “infinite”.
What do you guys think about these ideas ? Is there a better way to do this ?