# Historian Data Pruning

**URL:** <https://forum.inductiveautomation.com/t/historian-data-pruning/41587>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 16, 2020, 10:03pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587 "2020-12-16T22:03:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [December 16, 2020, 10:03pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/1 "2020-12-16T22:03:32Z")

</div>

I have a historian that has been collecting since 2015 with data pruning disabled. I recently enabled the data pruning at 2 years as shown in the screen shot. The data is partitioned into one month increments. So far no data has been removed.

Is there a step I missed? If there isn’t, when does the prune feature remove data?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/08dd2c8b0142281954a1e07126bf31ea3430fd09.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/3/c3577b17cc9c50e65b6124216663191ea471a14a.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 16, 2020, 10:29pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/2 "2020-12-16T22:29:14Z")

</div>

The `tags.history.query.PartitionManager` logger on DEBUG/TRACE may have some information; the prune task is supposed to execute every 10 minutes.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [December 16, 2020, 10:56pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/3 "2020-12-16T22:56:40Z")

</div>

```auto
INFO | jvm 1 | 2020/12/16 14:36:58 | D [t.h.q.PartitionManager] [22:36:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0]] Query: 'SELECT "pname", "start_time", "end_time", "blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<=? and "end_time">=? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "start_time" ASC' Params: [[3, 1607862600000, 1607257800000, 604800000]] queryid=8ec1d362
INFO | jvm 1 | 2020/12/16 14:36:58 | D [t.h.q.PartitionManager] [22:36:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0], sqlt_data_3_2020_11 [Sun Nov 01 00:00:00 PDT 2020-Tue Dec 01 00:00:00 PST 2020 @ 0]] Query: 'SELECT TOP 2 "pname", "start_time", "end_time","blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "end_time" DESC' Params: [[3, 1607257800000, 0]] queryid=8ec1d362
INFO | jvm 1 | 2020/12/16 14:36:58 | D [t.h.q.PartitionManager] [22:36:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0]] Query: 'SELECT "pname", "start_time", "end_time", "blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<=? and "end_time">=? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "start_time" ASC' Params: [[3, 1607862600000, 1607862600000, 0]] queryid=8ec1d362
INFO | jvm 1 | 2020/12/16 14:38:08 | D [t.h.q.PartitionManager] [22:38:08]: Ignition_History Partition query returning result set: [] Query: 'SELECT "pname", "start_time", "end_time","blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "end_time"<=? ORDER BY "start_time" ASC' Params: [[3, 1545086288425]] 
INFO | jvm 1 | 2020/12/16 14:38:08 | D [t.h.q.PartitionManager] [22:38:08]: Ignition_History Tag History maintenance task ran and did not delete anything. 
INFO | jvm 1 | 2020/12/16 14:48:08 | D [t.h.q.PartitionManager] [22:48:08]: Ignition_History Partition query returning result set: [] Query: 'SELECT "pname", "start_time", "end_time","blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "end_time"<=? ORDER BY "start_time" ASC' Params: [[3, 1545086888415]] 
INFO | jvm 1 | 2020/12/16 14:48:08 | D [t.h.q.PartitionManager] [22:48:08]: Ignition_History Tag History maintenance task ran and did not delete anything. 
INFO | jvm 1 | 2020/12/16 14:51:58 | D [t.h.q.PartitionManager] [22:51:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0]] Query: 'SELECT "pname", "start_time", "end_time", "blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<=? and "end_time">=? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "start_time" ASC' Params: [[3, 1607862600000, 1607257800000, 604800000]] queryid=8ec1d362
INFO | jvm 1 | 2020/12/16 14:51:58 | D [t.h.q.PartitionManager] [22:51:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0], sqlt_data_3_2020_11 [Sun Nov 01 00:00:00 PDT 2020-Tue Dec 01 00:00:00 PST 2020 @ 0]] Query: 'SELECT TOP 2 "pname", "start_time", "end_time","blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "end_time" DESC' Params: [[3, 1607257800000, 0]] queryid=8ec1d362
INFO | jvm 1 | 2020/12/16 14:51:58 | D [t.h.q.PartitionManager] [22:51:58]: Ignition_History (id=8ec1d362) Partition query returning result set: [sqlt_data_3_2020_12 [Tue Dec 01 00:00:00 PST 2020-Fri Jan 01 00:00:00 PST 2021 @ 0]] Query: 'SELECT "pname", "start_time", "end_time", "blocksize", "flags" FROM sqlth_partitions WHERE "drvid"=? and "start_time"<=? and "end_time">=? and ("blocksize" is NULL or "blocksize"<=?) ORDER BY "start_time" ASC' Params: [[3, 1607862600000, 1607862600000, 0]] queryid=8ec1d362

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 16, 2020, 10:59pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/4 "2020-12-16T22:59:26Z")

</div>

That query is asking for `drvid=3`, but your screenshot is a bunch of tables from `drvid=1` (the first digit in the `sqlt_data_X` table names). Look at what’s in the `sqlth_drv` table - either you’ve changed gateway names, and the old gateway name is what all the `drvid=1` entries were logged under, or there’s another gateway running somewhere else that’s storing to the same DB as `drvid=1`.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [December 16, 2020, 11:03pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/5 "2020-12-16T23:03:22Z")

</div>

Starting in Feb. 2020 the table names are dbo.sqlt\_data\_3\_2020\_02. I know we have changed this gateway’s name. It may have been around then. Is there a nice way to get the tables dropped or do I need to do it by hand?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [December 16, 2020, 11:04pm UTC](https://forum.inductiveautomation.com/t/historian-data-pruning/41587/6 "2020-12-16T23:04:18Z")

</div>

This is sqlth\_drv. There are no gateways currently running called ignitionproduction.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7b3cf15771653f6f2ea7012bf3d136c3982c3d25.png)
