Hi guys, May I know that how many days the tag history will be store in the database ? If YES, where should I set the settings ?
Hi @tohhy-pm17, it will not have a limit unless you configure data pruning (or setup your DB to prune the data outside of Ignition). Please refer to the Data Partitioning and Pruning section in the manual. This describes the appropriate Gateway Tag History settings to configure.
If you have any further questions, let me know.
Thanks @matthew.ayre for your reply. One more question for me
Currently, I would like to write a SQL query to retrieve the tags value from the database but I found out that the data of tags value have been separated which us 2021_03 and 2021_04. May I know that it is possible to combine all the tags value table together instead of separated it by months ?
By default Ignition will partition the data by month and create a new table (to improve query performance). This can be configured differently in the Gateway settings mentioned earlier.
If you are looking to do this from the SQL it largely depends on what database you are using. For MSSQL you could use UNION to combine data from several SQL queries, although this could get quite messy with the changing table names. Others on here may have a better method.
If you are looking to display the historian data in Ignition, there are components that do this natively, without the need for the SQL query. Depends on what you are aiming to do with the historian data.
Tag History was designed to “hide” all of the SQL manipulations required when accessing manually partitioned tables. Use system.tag.queryTagHistory() to retrieve your data, not the
system.db.* functions. Accessing tag history directly in SQL is not supported. (Future changes in Ignition could break your custom SQL, and it would be considered your own fault.)
Otherwise you could use transaction groups to build the table as you want with custom column names.
In transaction groups you can also specify how long you want to keep the data in the table with "Delet records older than " option
Thanks all of you for the help.
Hi @pturmel , may I know that where should I write the script of system.tag.queryTagHistory()
You are trying to use python in an expression binding. Only expression functions can go in expression bindings, and querying tag history isn’t one of them. Because there’s a Tag History binding type that you should be using. Right there in your screen shot. It is the binding equivalent of system.tag.queryTagHistory().
To use it, you will have to construct any complex calculations in separate bindings (on custom properties), and reference the result of those in your Tag History bindings.
Thanks for the information @pturmel . Therefore where is the suitable way to write the system.tag.queryTagHistory(). It is inside the Configure events of the table.
Actually, I would like shows the tags data in a table format.
Now that we know what you are trying to do, scripting is not the most appropriate way to deliver data to your component (whether chart or table). Use a Tag History binding.