# Downsampling old data

**URL:** <https://community.influxdata.com/t/downsampling-old-data/20540>\
**Category:** InfluxDB 2\
**Tags:** downsample\
**Created:** [June 28, 2021, 8:19am UTC](https://community.influxdata.com/t/downsampling-old-data/20540 "2021-06-28T08:19:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![airvb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/airvb/32/7690_2.png) [@airvb](https://community.influxdata.com/u/airvb)\
**Post date:** [June 28, 2021, 8:19am UTC](https://community.influxdata.com/t/downsampling-old-data/20540/1 "2021-06-28T08:19:43Z")

</div>

Bonjour ,  
I started to collecting iot data since may 2021.  
Now i try to downsampled datas to anoher bucket.  
i have this task who it working well: ( 1hour mean )

option task = {name: “test\_1h\_means”, every: 1h}  
from(bucket: “espeasy”)  
|\> range(start: 2021-05-11T12:00:00Z, stop: -1h)  
|\> filter(fn: (r) =\>  
(r[“topic”] == “T\_maison\_3/sensors/Temperature”))  
|\> filter(fn: (r) =\>  
(r["\_field"] == “value”))  
|\> aggregateWindow(every: 1h, fn: mean)  
|\> to(bucket: “downsampling-test”, org: “oNe”)  
|\> set(key: “temp\_test”, value: “testmaison\_moyenne”)  
|\> to(bucket: “downsampling-test”, org: “oNe”, tagColumns: [“test\_moyenne”])

Firt time running the task, bucket downsampling-test is filling well.

I imagine in few months, this task had to calculate the mean for a large amount of data as it takes beginning starting date 2021-05-11.

Is that the best practice ?  
Have a ‘one shot task’ to retrieve data from the beginning and another one with one day before range for just collecting the last day data ?

Or there is another way ?

Thanks
