queryTagHistory returning more than expected vs tag history binding or simple query

I'm having some issues getting system.tag.queryTagHistory to give me the data 'as-stored' from the database. To my understanding, using -1 for returnSize should give something similar to as-stored, but I'm getting an excess of points returned from my query. For what it's worth, I can change the returnSize and it will scarely ever give me the number I want, even toggling noInterpolation True or False. Maybe that's a hint. Here's the script:

endTime = system.date.now()
startTime = system.date.addSeconds(endTime, -1*durationInSecs)
queryResults = system.tag.queryTagHistory(paths=historicalPaths, startDate = startTime, endDate=endTime, noInterpolation = True, ignoreBadQuality=True,	returnSize=-1)

As it stands, the tag history script returns about 460 entries from my last 24h.
I'm comparing my queryTagHistory with the tag history binding and a direct sql query, which both come up with ~230 entries, which I believe is correct. Any obvious 'gotcha's I'm missing here with my script?

Going off of memory, -1 is 'OnChange', 0 is 'natural' for returnSize.

1 Like

You are correct.

1 Like

That is correct. I must have completely missed that. Thanks for the quick fix.

In addition, I've just now noticed that each of my data is being consistently doubled for some reason. Just now clicked that it probably has very little to do with the system function itself. Probably a bug completely elsewhere outside of the historian query that's doubling the query.

Edit: it was. Recklessly copying the 'looping through a dataset' section from the documentation had me looping an additional time for each 'col' in addition to each 'row' doubling the points.

This is it though, thanks.

Are you return data for two tags in "Wide" mode? Wide return format and "As Stored" format are not compatible.