Sqlth_te tag history table question

Hello, we have a project where we are selectively enabling tag history using scripts. Part of our project requires that we keep some additional meta data in other tables for these tags when we do this. Our script is using the system.tag.configure method to enable the history on these tags and that seams to be working correctly. We then want to use the ID field from sqlth_te as a foreign key in our other table to maintain the relationship with the additional data. Our current script will attempt to query sqlth_te just after the system.tag.configure call to obtain the ID field from sqlth_te. This seems to work inconsistently. Sometimes it will work correctly however many times we notice there is significant delays before an entry appears in this table. There have also been times where an entry never seems to appear in this table.

We are assuming this might be caused by some internal caching being done in the historian module thats delaying writes to SQL but I am not sure about that.

Is there another way for us to obtain this ID field from sqlth_te? Perhaps a way to query the cache, or a flush command, etc… We have to date been unsuccessful in finding a way using the documentation and forum but perhaps we just missed something

Thanks for any tips on this

My experience with this has been that the sqlth_te table is only written to when the tag value changes. One way perhaps to get around this is to restart the tag. I would do some testing with a memory tag to try to run down the inconsistency.

Are you using events in your Database to do this or trying to do it in Ignition? If you just let the Database watch for the event, it will add it to your meta table whenever Ignition writes it. Now you don’t have to worry about the timing problem. Just a thought.

-Brandon