Influxdb: support select count(time) from ... or select count(1) from ...

Created on 23 Sep 2014  ·  15Comments  ·  Source: influxdata/influxdb

It would be nice if time and sequence_number would become more similar to regular columns. E.g. it to be able to determine the number of rows in a series without knowing the names of the available columns.

On a related note, "select time from series" is always empty.

RFC

Most helpful comment

Excuse me for my blatancy but why do you keep closing issues if they haven't been addressed..? Just because the version number of influx has been bumped by 0.1, doesn't mean all the issues from the previous version magically disappeared. I understand issues are perhaps piling up, but hiding obvious problems under the rug isn't really helping anyone. Of course you can just close the case to virtually lower the number of tasks but then someone else has to stumble upon the same issue has to create a new task which explains the same thing over again so what's the point?

All 15 comments

+1

My use case is a table whose entries periodic status updates of processes, in order to easily calculate the duration of some process I would like to execute:

select difference(time) as duration, pid from process_updates group by time(30m), pid

In addition when grouping by some time interval, the time column values are rounded. It would be nice if I could set manually the result time value, e.g.:

-- set last update time as time value of a result row
select last(time) as time, pid, ... from process_updates group by time(30m), pid
-- or, set fist update time as time value of a result row
select first(time) as time, pid, ... from process_updates group by time(30m), pid
-- or, even set an arbitrary value
select <some-other-column> + 10 as time, pid, ... from process_updates group by time(30m), pid

I just stumbled across this issue as well. My use case is to determine the first (and last) point in a given series.

My approach is

SELECT time FROM test ORDER DESC LIMIT 1
SELECT time FROM test ORDER ASC LIMIT 1

As @jordens already mentioned, this will _always_ yield in an empty result set. Since the points in my series are not necessarily have all attributes, the only workaround for me is to SELECT *, which works, but might not be that efficient I guess.

I'm on OS X 10.10 and running InfluxDB v0.8.5 (git: 9485e99) (leveldb: 1.15)

Also hitting this limitation.

I’m trying to display the time which has passed since the monitored program has last executed a periodically occuring cleanup job. To that end, I’m logging the timestamp of the last execution and trying to use e.g. “SELECT value - time AS time_since_last_cleanup FROM "last-cleanup"”, but it fails:

Server returned (400): Field time doesn't exist in series last-cleanup

You can't just report a single data point when that runs and then do the math client side? Like, when the job runs report a point with value = true. Then select value from last-cleanup limit 1. Then just look at the timestamp there vs. the UTC (or whatever your server is set to) current on the client?

We'll do some work on 0.9.0 to make time a more standard looking column

I could do that, but then I cannot integrate this fact into my grafana dashboard. I need a graphable expression for that :).

ok, good point. I'll keep this open and see if we can address in 0.9.0.

:+1: for time to be allowed in the SELECT clause and within functions like MIN

+1 really need to have way to query the time field and do some basic math. ATM this is one of the missing features that we need before we can use influxd

Issue has drifted from the original request. Please open a new issue for functions/operators on time.

@beckettsean Has the original issue been adressed?

@jordens the original issue has not been addressed, but if it is still relevant a cleaner, newer issue using 0.9 examples is preferred. It is not possible to do something like SELECT COUNT(*) FROM measurement, it still requires that you know at least one field, e.g. SELECT COUNT(value) FROM measurement.

Excuse me for my blatancy but why do you keep closing issues if they haven't been addressed..? Just because the version number of influx has been bumped by 0.1, doesn't mean all the issues from the previous version magically disappeared. I understand issues are perhaps piling up, but hiding obvious problems under the rug isn't really helping anyone. Of course you can just close the case to virtually lower the number of tasks but then someone else has to stumble upon the same issue has to create a new task which explains the same thing over again so what's the point?

Can we please reopen this issue exactly for what the OP asked in the first comment (minus the sequence_number bit)?

In other words, SELECT COUNT(time) FROM measurement WHERE... should return the total number of points in the measurement satisfying the WHERE condition.

@dandv you can't SELECT COUNT(time) because it doesn't exist as a column. Every column keeps its own time so you have to specify some column name other than time. This is part of the lower level implementation and is very unlikely to change.

Can we please reopen this or #8882.

Was this page helpful?
0 / 5 - 0 ratings