I've noticed some interesting behavior when I tried to run a UNION query with a custom constant field.
Consider the attached model, Union_With_Field.fsm (2021.0.3). It fills a statistics collector ProcessorStaytimevsTime and a calculated table based on that.
When executing the query using the timing script at the bottom, the query takes about 2700 ms on my computer:
SELECT Object, Time, Staytime FROM ProcessorStaytimevsTime WHERE Time > 0 UNION SELECT Object, Time, Staytime FROM ProcessorStaytimevsTime WHERE Time < 0
Fun fact, the second part (WHERE Time < 0) does not even contribute any rows in this case. When I remove it and just run
SELECT Object, Time, Staytime FROM ProcessorStaytimevsTime WHERE Time > 0
it updates almost instantly (2 ms according to the script).
In the actual model where I found this, I had a table with three data fields (Time, A, B, C) and I was using a double UNION to turn this into a table with columns Time, Type, Value (where Type = "A", "B" or "C") so I can plot A, B and C as three series in the same graph. That query takes 60 seconds (!) to complete.
Question 1: Is it possible to optimize this (I assume that it becomes so slow because the UNION forces it to copy the whole result set somewhere, but I'm sure it is possible to improve).
Question 2: Is there a 'pivot' function in FlexSim 2021, that allows me to plot my three columns A, B and C as three series in the same graph without the calculated table?