# Downsampling batch-imported-data automatically

**URL:** <https://community.influxdata.com/t/downsampling-batch-imported-data-automatically/4001>\
**Category:** Systems\
**Tags:** influxdb\
**Created:** [February 14, 2018, 7:56am UTC](https://community.influxdata.com/t/downsampling-batch-imported-data-automatically/4001 "2018-02-14T07:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TSasaya](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@TSasaya](https://community.influxdata.com/u/TSasaya)\
**Post date:** [February 14, 2018, 7:56am UTC](https://community.influxdata.com/t/downsampling-batch-imported-data-automatically/4001/1 "2018-02-14T07:56:31Z")

</div>

Can influxdb downsamples batch imported past-data with a continuous query automatically?

I have started to handle data from 10,000 sensor and 100,000 network devices for Machine Learning based anomaly-detection.

I want to process data like following;

1. Create CQ, which aggregate minute interval data to hourly interval or daily interval.
2. Import daily or weekly data from csv to influxdb with golang client.
3. Downsample data by some trigger.

I want to downsample from data like this,

> select count from data where time \>= ‘2016-12-31T15:00:00Z’ and time \<= ‘2016-12-31T16:59:59Z’  
> name: data  
> time count

* * *

2016-12-31T15:00:00Z 100  
2016-12-31T15:01:00Z 100  
2016-12-31T15:02:00Z 100  
2016-12-31T15:03:00Z 100  
:  
:  
:  
2016-12-31T15:57:00Z 100  
2016-12-31T15:58:00Z 100  
2016-12-31T15:59:00Z 100  
2016-12-31T16:00:00Z 200  
2016-12-31T16:01:00Z 200  
2016-12-31T16:02:00Z 200  
2016-12-31T16:03:00Z 200  
:  
:  
:  
2016-12-31T16:57:00Z 200  
2016-12-31T16:58:00Z 200  
2016-12-31T16:59:00Z 200

to data like following;

> select count from data where time \>= ‘2016-12-31T15:00:00Z’ and time \<= ‘2016-12-31T16:59:59Z’  
> name: data  
> time count

* * *

2016-12-31T15:00:00Z 6000  
2016-12-31T16:00:00Z 12000

And, a continuous query that I have created is following:

name: cq\_test  
name query

* * *

sum\_count\_10m\_cq CREATE CONTINUOUS QUERY sum\_count\_10m\_cq3 ON cq\_test RESAMPLE FOR 10m BEGIN SELECT sum(count) INTO cq\_test.autogen.sum\_count\_10m\_cq3 FROM cq\_test.autogen.data GROUP BY time(10m) END

Is it possible for bulk-import to trigger/execute continuous queries or I have to aggregate it manually?

//Regards  
Taisuke Sasaya
