Deleting historical records from the module code

I have a module that is using the DatasourceManager to create a table in a SQL db and write BasicHistoricalRecords. I would like to be able to prune data from this table that is too old, or based on another event. I cannot find anything in the SDK to support this effort to delete records from that table. Is that not possible? The only option I have at this time would be to use a SQL job to delete records but I would love to leave this functionality inside of the module code.

Wait, as in, you've got a module (that's not a historian implementation) that's creating BasicHistoricalRecords and, what, calling storeToConnection directly? That's...unorthodox. BasicHistoricalRecord has a lot of assumptions baked into it related to the tag historian, and really isn't meant to be a general purpose class.

I am using storeHistory() to write the BasicHistoricalRecord. So far it is working great but it would be nice to manage the table size from within the module to allow for the removal of data that is too old.

The customer has Remote Tag Providers that are already storing values in a database but they don't want any additional load put on those databases for data retrieval. I don't see how you could mark a tag to be using more than one historian so this approach has allowed for storage of a subset of tags on the RTP in a separate database. I don't see how to take advantage of the partitioning and pruning functionality on this secondary database though.

This seems like the entire operation could just be managed via the tag history splitter, and then you don't even need a custom module - just configure native pruning on each 'sub' connection of the splitter.

1 Like

Thanks for the response. I will look into the Splitter concept. The Remote TP has 80k tags but we only want to collect 5000 of them into a separate DB to prevent any additional load on their primary DB.