Queries with parameters not updating


I have chained queries where the primary query fetches data from an external database and returns a “long” table of results and then simple separate queries that return subsets of that based on a dropdown parameter, e.g. SELECT * from cached_query_123 WHERE area = '{{ area }}'. This latter query doesn’t seem to be updating. I have set a refresh schedule of one hour, but the query table doesn’t show a latest execution time at all and dashboards (which have a global parameter) show old data. The query does execute fine if I run it manually or hit the refresh button on the dashboard, but it just doesn’t update in the background and not on dashboard page load either. What’s wrong here? How or why does parametrization affect the updating?

This is on a self-hosted Redash 7 running via Docker.

When you set a schedule for a parameterized query, the scheduler will only execute the query with the default parameter value. This execution won’t be saved in as the latest_query_data_id, but will be available if you open the query.

Does this explain the behavior you see?

What I see is three things:

  1. The list of queries shows “Last Executed At” blank for all parametrized queries
  2. The query itself shows “Updated X hours ago” where X is greater than the defined update schedule
  3. Visualizations on the dashboard also show “(refresh icon) X hours ago” where X is greater than the defined update schedule

Both the query and dashboard have the same default parameter value.

Is latest_query_data_id what the dashboard uses? I’d expect if a user opens a dashboard, the data it shows should be up to date without needing to hit refresh.

We’ve been seeing the same thing. I believe it started when we upgraded to 7.0, but it’s possible it was happening with 6.0 as well. Most of our queries are set to update everyday, but now we have to regularly tell people to hit “Refresh” on dashboards to view updated data. The majority of our queries are also using parameters, we have over 600 queries and 90 dashboards (if this matters). Our main data source is a PostgreSQL database.

From the looks of things, the queries are just not updating at all, going multiple days without running. Looking at the ‘query_results’ table, you don’t see any results either.

Same problem here. Any workaround?

Hi @vnnw, can you provide more information about what isn’t working on your end? Which version of Redash are you using? Self-hosted or not? Which data sources don’t appear to be updating?

I can’t reproduce this. Here’s what I tried:

  1. Create a scheduled, parameterized query that hits Postgres
  2. Use the query results data source to select a portion of the returned data from step 1.
  3. Monitor the results of step 2 to confirm that the query from step 1 runs regularly and the query result is successfully updating.

Nothing unexpected happens with this setup. Also @otsaloma to see if the OP ever resolved this on their end.

Thanks for the reply.
I am running a self-hosted Redash using the master branch from Github (8.0.0 beta).
I added a query with a Date-Range parameter like Last 7 days, and Redash won’t refresh the query.
I know this release is premature but hope to find a workaround to get over it as this problem happened before.

Can you give more detail? What happens when you refresh the query manually? Does it hang forever or will it return a result? Is it just the scheduled query that fails?

What happens when schedule a query without a parameter?

I still see this. I can reproduce it by doing the following.

  1. Add a SQL query against a database, e.g. SELECT * FROM table LIMIT 1000;. Set to update every five minutes.
  2. Add a parametric query, e.g. SELECT * FROM cached_query_123 WHERE area = '{{ area }}' where 123 is the query number of the previous step. Replace “area” with whatever data you have available. Set to update every minute.
  3. Add a dashboard showing the table from the previous step. Wait more than five minutes and you’ll see “6 minutes ago” (and ever more as you wait longer) at the bottom of the dashboard widget. Reloading the page doesn’t change the value. Hit the refresh button at the top right of the page and you’ll see “0 minutes ago” and correspondigly the latest data.
1 Like

Thanks @otsaloma. I reproduced this on the latest SaaS build so it’s not just your installation.

Hey @arikfr, is this a bug or an expected behavior? I can open an issue on GH if needed.

Scheduled query without parameter works fine.
After a study of the code, I found that there may be two problem related with this problem:

1 Like

You have the right idea. @arikfr showed how to circumvent this limitation using the API here. Which means it’s possible to refresh parameterized queries.

But I’m not certain if the present behavior is a bug or is intentional. In the first case we can open a bug report. In the second case we can label this thread a feature request for the community to consider.