Correct way to use WHERE clause?

Hello Community,
I need some input on the following topic,
I am currently running InfluxDB 1.8.x and making a following query to DB, SELECT time as "someMeasuremet.time", name as someMeasuremet.name" from someMeasuremet WHERE "someMeasuremet._level"='${levelVal}' and as per WHERE clause documentation, we should always put “Tag Keys” inside WHERE for better performance, but in my case I have “someMeasuremet._level” as a tag key and also as a field key. So my question is will this make any problem ?

Looking for feedback :slight_smile:

From what I’ve seen so far, the same key can’t exist as a tag and as a field, if that happens (usually for a wrong insert) the latest one to arrive gets renamed to {keyname}1 or something similar.

Therefore I suggest you have a good look at your fields and tag keys because something should be wrong.

About the WHERE clause:

  • The docs suggest using it on tags because they are indexed therefore easy to filter
  • You can also filter field values, but that requires a scan of the data (as fields are not indexed). I’m using it, but only for small time ranges or small amount of data anyway and I’ve never had problems