Intuitively, if you set maxItems to 10, then you only expect up to 10 rows back from the service. In my experience, the number of rows returned is about four times whatever I set maxItems to. In a simple empirical test, I tried a variety of values of maxItems for the same timeframe, and here's what I got back:
Furthermore, I would expect as I increase maxItems, I would simply get additional rows with a later time; this too is not what happens. I always get new rows with each increase of maxItems, but they aren't all later in time! I've summarised this below:
|timestamp||First value of maxItems where timestamp is seen|
Unless I'm missing something fundamental, maxItems really doesn't work properly!
PS - I've seen a post by Pat Nash related to this, but it doesn't address exactly what's going on with maxItems!
I just tested this in 7.2.4, and there were no issues with either streams or value streams. Perhaps if this was a bug, it is already fixed in newer versions.
I just tested this in 7.2.5 and the problem persists. I clicked the "Test" button for QueryPropertyHistory on one of my Things, set maxItems to 10 and clicked "Execute Service". I got back new fewer than 50 items! I tried again, setting maxItems to 1 and still got back 5 items. maxItems=2 => 10 items.
Can you tell me specifically what type of stream you are using? Where is the data coming from? Are you in Neo or Postgres?
It's a Value Stream attached to a Thing that has a number of logged properties (the one I just checked has 28). I don't know whether it's significant, but in the case of the one I just checked, the Value Stream is attached to the Thing Template. There's nothing special about the Value Stream as far as I can tell: it has minimal settings and uses the ThingworxPersistenceProvider. I'm using Postgres.
By the way, I've upgraded to ThingWorx 7.3 and this issue is still evident. When I tried QueryPropertyHistory just now (via the "Test" button) I requested a maximum of 5 items and got back 58!
Hello Richard Wiseman,
Just tested on Thingworx 7.2.1-b71 with H2. Logged a lot of Number properties to Value Stream.
QueryPropertyHistory is working fine, returning [maxItems] rows. If I need to get oldest data first, this boolean param is also working.
Could you provide a more detailed info regarding your environment, as Tori Tielebein asked.
What version of Thingworx and persistence provider do you use? What type of property do you log? From the service you use I can guess that you log to the Value Stream. Do you invoke QueryPropertyHistory on the Thing, not on the Stream?
Now I'm not able to test and replicate it on Postgre-backed Thingworx, I'll be able to do it later, so after that I'll come back to you with the results.