# Slow queries when using variable in panel query

**URL:** <https://community.grafana.com/t/slow-queries-when-using-variable-in-panel-query/41946>\
**Category:** InfluxDB\
**Created:** [January 21, 2021, 12:04am UTC](https://community.grafana.com/t/slow-queries-when-using-variable-in-panel-query/41946 "2021-01-21T00:04:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikecalp](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mikecalp](https://community.grafana.com/u/mikecalp)\
**Post date:** [January 21, 2021, 12:04am UTC](https://community.grafana.com/t/slow-queries-when-using-variable-in-panel-query/41946/1 "2021-01-21T00:04:11Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![wlargou](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/wlargou/32/14374_2.png) [@wlargou](https://community.grafana.com/u/wlargou)\
**Post date:** [January 21, 2021, 11:26pm UTC](https://community.grafana.com/t/slow-queries-when-using-variable-in-panel-query/41946/2 "2021-01-21T23:26:44Z")

</div>

Hi,

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

Good Luck
