influxDB subquery issue

influxDB version:

Connected to http://localhost:8086 version v1.4.2
InfluxDB shell version: v1.4.2

problem recurrent

I have a such measurement named cpu:

>select * from cpu
name: cpu
time                host region   usage
----                ---- ------   -----
1513740196274126153      beijing  90
1513740228010334120 h1   beijing  90
1513740231403477934 h2   beijing  91
1513740235267749359 h3   beijing  96
1513740245876102594 h1   shanghai 91
1513740249124344717 h2   shanghai 92
1513740252284391121 h3   shanghai 93
1513756147263126278 h3   beijing  100

> show tag keys from cpu
name: cpu
tagKey
------
host
region

execute this statement:

> select max(usage) from cpu group by time(3000h),host
name: cpu
tags: host=
time                max
----                ---
1512000000000000000 90

name: cpu
tags: host=h1
time                max
----                ---
1512000000000000000 91

name: cpu
tags: host=h2
time                max
----                ---
1512000000000000000 92

name: cpu
tags: host=h3
time                max
----                ---
1512000000000000000 100

time is enough large so each series can be aggregate to one point
It's return FOUR series and only return tags host
and then I execute a subquery:

> select top(max,region,host,5) from (select max(usage) from cpu group by time(3000h),host)
name: cpu
time                top region host
----                --- ------ ----
1512000000000000000 100        h3
1512000000000000000 93         h3
1512000000000000000 92         h2
1512000000000000000 91         h2
1512000000000000000 91         h1

the number of series is more than subquery's!

Expected:

in influxDB doc, it says:

InfluxDB performs the subquery first and the main query second.

so it should execute subquery firstly, and the result of subquery only has four series and one tag:host, so I think add region in main query will be same as add a not exist tag, and has no influence to result because there not be a tag region in the result of subquery. just like this:

> select top(max,"not-exist-tag",host,5) from (select max(usage) from cpu group by time(3000h),host)
name: cpu
time                top not-exist-tag host
----                --- ------------- ----
1512000000000000000 100               h3
1512000000000000000 92                h2
1512000000000000000 91                h1
1512000000000000000 90

Thank you.

你可能感兴趣的:(influxDB subquery issue)