Could you please help me on how to delete bulk tags data from PI AF. I have the opinion that it can be done in SQL using commands. Please share your opinion on other options.
Do you mean historical data which is stored in atributes using PI point data reference?
If so you could delete the data using OLEDB provider with SQL type statements as you said. something like:
DELETE piarchive..picomp2 WHERE tag='sinusoid' AND time >= 't'
Or you could using piconfig as well as expolained in this KB article:
3065OSI8 - How to delete data in PI archives How to delete snapshot or archive values
Technically, the statement uses PI OLEDB and directly targets the PI Data Archive. If one would need to remove data from PI AF, my expectation is that a removal af data from PI AF attributes is required. There is no easy way to do this in PI OLEDB Enterprise. The Data schema only gives read-only access to the data of AF attributes.
You could get the configstring attribute from the ElementAttribute, check the column 'DataReferencePlugInID', parse the string to get the PI tagname out, and use the example of Ana Revert Tomas to delete the PI data.
You can't lookup the PI DataReference ID though, so that's soemthing you need to hardcode.
So concluding, SQL is not the easiest way to resolve this problem, as parsing the Configstring is the main issue here. Using the AFSDK would be much easier in most cases as John Messinger explained.
This could also be helpful: 3065OSI8 - How to delete data in PI archives How to delete snapshot or archive values
You could also do it using the AF SDK if you are looking at other options:
AFValues values = attribute.Data.RecordedValues(timerange, AFBoundaryType.Inside, null, null, true);
Whatever your chosen method for deleting data be VERY cautious as to how much data you send to the PI Data Archive to be removed - you need to batch up the deletes and find your system's sweet spot. It is easy enough to affect system performance to the point that it become unresponsive whilst it processes backlogs of events to be removed.
Please let us know if the above answers solved your issue, if you used one of them please mark it as correct answer. If you have used and alternative please let us know for future reference
Thank you !
Retrieving data ...