Influxdb: count() doesn't support tag

Created on 27 Jun 2017  路  7Comments  路  Source: influxdata/influxdb

It's diffrerent from mysql
I know we can use show tag values to do the same thing but we may query very more times

1.x areinfluxql flutriaged kinfeature-request wontfix

Most helpful comment

A current workaround for this is to trick the system using subqueries. You just need to choose a known field and do this:

SELECT count(distinct(host)) FROM (SELECT value, host FROM cpu)

Not as performant as an ideal solution, but it works.

All 7 comments

A current workaround for this is to trick the system using subqueries. You just need to choose a known field and do this:

SELECT count(distinct(host)) FROM (SELECT value, host FROM cpu)

Not as performant as an ideal solution, but it works.

This would be awesome, to be honest :heart:

@jsternberg it works,thx
we may make the tag be a redundancy field.it may waste some storage but the performance may be good

This would be extremely useful. I often have a need to visualize the number of rows that match certain criteria (e.g. in Grafana). I'm using the workaround suggested by @jsternberg , but it would be nice if this were baked into a real feature of the language.

SHOW TAG VALUES CARDINALITY FROM memcached WITH KEY = "host" WHERE environment =~ /^$country$/

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidgubler picture davidgubler  路  3Comments

deepujain picture deepujain  路  3Comments

jayannah picture jayannah  路  3Comments

dandv picture dandv  路  3Comments

allenbunny picture allenbunny  路  3Comments