-1

I am writing an app that will store regular temperature readings, and am looking to use Apigee App Services for the storage. However, to chart the temperature readings over time, it is inefficient to pull all the readings out over a period (e.g. a month) because there would be too many (there's one every 15 seconds or so), especially when the most common case would be to show a trend. The app could support (a) retrieving only every nth sample (for appropriate choice of n depending on the graph), (b) retrieving the average (or min, or max) of groups of n samples over the period, or (c) retrieving n, evenly spaced samples, over the period. However, it doesn't look like Apigee would support any of these using their data retrieval APIs.

I would've thought that retrieving time-series data in such a fashion is not an usual use-case, so hopefully someone's already tackled this. Is it possible?

Andrew
  • 19
  • 3

1 Answers1

1

One way you may accomplish this is by having a field (called sample_bin) that is assigned a value RANDOM(0-n) when you save it. Then, when you query the data, add in the condition that sample_bin = a specific number 0-n. This would save you from retrieving all of the records from the database to do the sampling. This should result in a more or less evenly distributed random sampling.

Mike Malloy
  • 1,520
  • 1
  • 15
  • 19
  • Thanks Mike. While something like this is definitely an alternative, it's not really an answer, as I'd need to set up all the data in advance to support every type of query I'd want. For example, I'd need a field to allow for weekly series queries, another for daily, and other for monthly, etc. More data would be stored to allow for various time-series queries than would be stored for the readings themselves. I also thought instead of a random function, using a modulo of the time/date would allow for a similar trick. Is this approach what everyone does? – Andrew May 25 '14 at 13:23