Refresh query on tab change

Hi,

Let’s say I have an app with 6 tabs and 6 queries. (one query per tab)
Is it possible to only execute the query of the tab that is viewed? At the moment all queries are executed on opening of the app, however that is not very efficient.
Changing the queries to ‘run query only when manual triggered’ prevents this, but is there a way to run the query when I change to tab2 etc?
I can of course add a button for that on each tab, but is there a more elegant option?

Thanks again,
Michel

You can disable the query unless that tab is active. That will cause it to run when the tab is opened.

However, I would also caution against this strategy, having used it myself in the past. It would slightly improve the first-load-time, but then the app actually becomes slower after that, since you’d have to wait for the query to run every time changing tabs.

1 Like

Thanks Byron! For as well as the explanation as the word of caution :+1:

Oh, one additional question though…

Most of my queries take 3-5 seconds in ReTool, which is a lot since they execute on my SQL Azure (West Europe) server in about 50 ms or less. The data is less than 10kb for each of them.

What might be the cause of this delay?

@mm79 could be for any number of reasons. Your Retool query needs to travel from the frontend to our backend (where credentials are stored), then to your database, then the data needs to come back to our backend, and then go to our frontend. We're definitely hoping to improve these latency numbers :slight_smile:

Thanks you again Justin. Is the time displayed on my frontend the total time?
I'm just wondering which part is the main cause of the delay.
But I'll just wait for any improvement then, since I think there's not much I can do.
May running queries in parallel be an issue?

Yes, the time on the fronted is the total time from when the query is initiated by the client to when it returns. Something else that doesn’t come in to play if you are directly running a query in the DB console or on a DB that is local to your network is that you’ll also need to download the return. So if the query return is sizable and your internet connection is a bit slow, then downloading the file could take longer than it takes for retool to run and return the query result.

Thank you Alex as well for your answer! As I stated before, the data is less than 10kb and the query execution time is less than 50ms. I forgot to mention that this time was measured on the client side (client statistics in sql management studio -> total execution time). This info might be of help to this request: Slow Retool apps Wanted!

(ps: I use SQL azure in West Europe and I connect from the Netherlands, which may explain why the query finishes so quick on my end)