Slow queries when using variable in panel query

Hello All,

I’ve been trying to debug an issue and just noticed when using a grafana dashboard variable on a panel takes significantly longer on generating panel data vs just inputting the regex in the influxdb query in the panel itself. Difference is somewhere like 5-10 minutes for the variable and a few seconds for the query
Grafana 6.3.5
Influx 1.7.10

Setup 1 - Variable - Query - InfluxDB data source - about 10 minutes to load panel
variable
select distinct(fruit) from data where (“fruit” =~ /^apple/)
Panel Query
select distinct(fruit) from data where (“fruit” =~ /^variable/)

Setup 2 - No variable used, just the influxdb query configured in the panel
select distinct(fruit) from data where (“fruit” =~ /^apple/)

Setup 2 only takes a few seconds, whereas setup 1 can take up to 10 minutes.

I also tried changing the variable to a custom definition and it seems to take just as long as setup1

Any help is appreciated, thank you!

Hi,

Did you try on newer versions, there have been improvements and bug fixes since the version you are using.

Good Luck