Sample Size and Aggregation Mode
The sample size determines how the query results will look. A Natural query will look up the logging rate for the queried tags, and return results spaced apart at that rate. This means that the return size will vary with the date range. An On Change query will return points as they were logged. This means that the results may not be evenly spaced. A Fixed query will return the given number of rows. Where data was sparse, interpolated values will be added. Where data is dense, the Aggregation Mode will come into play.
The Min/Max aggregation mode will return the min and max for every timestamp. The Average aggregation mode will return the average timestamp for data within the underlying range.
The return size determines how the underlying data is aggregated and/or interpolated. If a distinct return size is specified, that will be the number of rows in the resulting dataset. The special numbers 0 and -1 mean “Natural” and “On-Change”, respectively. “Natural” calculates a return size based on the rate of the logging historical scan classes. For example, if you query 1 hour of data for a scan class logging every minute, the natural return size is 60. "On-Change means that you’ll get an entry whenever any of the tags under consideration have changed.
Instead of defining a fixed return size, the parameters intervalHours and intervalMinutes can be used. These parameters can be used independently or together to define a “window size”. For example, if you defined a 1 hour range, with intervalMinutes=15, you would get 4 rows as a result.
The span of the query can be specified using startDate and endDate. You can also use rangeHours and rangeMinutes in conjunction with either start or end date to specify the range in dynamic terms. For example, you could specify only “rangeHours=-8” to get the last 8 hours from the current time. Or you could use “startDate=‘2012-05-30 00:00:00’, rangeHours=12” to get the first half of the day for May 30th, 2012.
The aggregation mode is used when the data is denser than what you asked for. This happens when using fixed return sizes, as there will often be multiple raw values for the window interval defined. Another common operation is to set the return size to 1, in order to use these aggregate functions for calculation purposes. The available functions are:
• “MinMax” - will return two entries per time slice - the min and the max.
• “Average” - will return the time-weighted average value of all samples in that time slice.
• “LastValue” - returns the most recent actual value to the end of the window.
• “SimpleAverage” - returns the simple mathematical average of the values - ((V1+V2+…+Vn)/n)