I’m currently using influxcxx client library to interact with InfluxDB v1.6.7~rc0.
In my code, I have querying a single datapoint by timestamp (Target time is 946684800) as:
SELECT * FROM BENCH_DB WHERE time = 946684800ms
However, as I progress towards creating a query for multiple datapoints by multiple random timestamps (This means that range query such as WHERE time >= xxx AND time <= xxx would not work either). Per my understanding it seems like InfluxDB does not support this type of query yet (Neither multiple OR operator or IN operator works).
EX: I want to query for all data that matches this list of target timestamps (946684800, 946684801, etc.)
SELECT * FROM BENCH_DB WHERE (time = 946684800ms OR time = 946684801ms)
@lvn2007 InfluxQL does not support the OR logical operator when using the time column (noted in the documentation). In newer versions of InfluxDB, this is still the same. This would be possible with Flux, but you’d have to use InfluxDB 1.7+ to have access to Flux.
Do you need to query by specific timestamps if the timestamps are random? Why not just use SAMPLE to return N random points from a queried dataset?
Hi Scott, thanks for your reply.
I’m not sure I understand your answer, perhaps you misunderstood my question.
I would like to query a random timestamp. Though, the target timestamps are decided on my end, not from picking randomly by the SAMPLE call.
Essentially, I would like to query the same way as the below but instead of making each individual query at a time, I would send it as a batch of timestamps and wait for results to return.
Gotcha. This isn’t possible with InfluxQL. InfluxQL doesn’t support the IN logical operator so you couldn’t pass a list or array. It also doesn’t support the OR operator on time values. I think the only way to do what you’re trying to do with the version of InfluxDB you’re using is to send a separate query per timestamp and combine the results client-side.