I’m curious about the best way to store parameters in an SQL Server database. In the beginning, I used the Tag Historian to save data, and Ignition automatically created its own database architecture, storing each parameter as a row and partitioning the tables by month.
Later, I ran into a problem: in production, they wanted to save a group of parameters per batch. I tried using Transaction Groups, but it became messy because I ended up creating a separate table for each position in the factory. To display the data, I first had to know the position in the factory and then write a specific query for each one.
Because of this, I decided to copy the same architecture used by the Tag Historian. I now save all parameters in a batch, linked by a column that indicates the batch_id. The problem is that when I try to display the data in a table, I need to pivot the results so they appear as columns instead of rows. Ignition does this automatically for historian tags, but in my case I need to do it manually in the SELECT query. Performance becomes terrible when large amounts of data are involved — it can take minutes to load the table, and I often get timeouts.
Is there a better way to pivot data in a table? I’ve read in some SQL forums that Excel has more powerful tools for pivoting than SQL, but what about Ignition?