4. Caching, local cells and scheduling
Now you've started building some queries, let's consider how we can optimise your canvas performance (before you go too far!)
Last updated
Now you've started building some queries, let's consider how we can optimise your canvas performance (before you go too far!)
Last updated
Using a combination of caching, local cells and scheduled queries you'll be able to explore your data more quickly - you're not waiting for your database to execute a query every time a cell changes, instead it all happens really fast in your browser.
Caching your results means that your query results are stored in the canvas. This means when your canvas is refreshed, or someone else joins your canvas, the queries aren't run against your database again, and so will load immediately (showing the results from when they last ran against the database). When you query the results of your cached data using local cells (DuckDB or Python), these queries execute much more rapidly because they're running locally in your browser.
Local cells (DuckDB or Python) run in-memory in your browser. This means you can query cached database results immediately, and you don't have to wait for your query to be returned from your database.
It's important to be aware that there is a limit on the amount of data that a cell can return (approximately 120MB), so it's best to get your results down to a reasonable size before switching to DuckDB.
If you're unable to reduce the size of your data, you can still make use of local cells to first prototype locally then revert back to live data on your database for the full results.
With scheduling you set your canvas to automatically run at a specific interval. For example, you may want to set your queries to refresh every morning at 7AM before other canvas viewers typically open your canvas. If the rest of your canvas is set up to heavily make use of local cells, then when users come in later in the day they'll not be querying your database, meaning canvases run fast for the user, and the database load (and potentially costs) are lower.
💡 Learn more about caching and scheduling in our guides here.