Manage queries and results
Control when queries are executed, and how to access their results.
Last updated
Control when queries are executed, and how to access their results.
Last updated
Most of the time when using Count, it isn't necessary to monitor query execution - the appropriate queries will be submitted automatically based on your changes to cells and other canvas objects.
In some cases it may be important to control exactly which queries are executed - for example, if the query is expensive or your database is expected to be under heavy load. Below you can read more about the query lifecycle in Count, and how to control queries and their results.
When a query begins executing in a Count cell or visual, the current state of the query is displayed in the output area:
The stages are:
Connecting - your browser has asked for a query to be submitted. If other queries for the same connection are also waiting to be executed, the number of waiting queries will also be displayed.
Running query - Count has sent the query to your database, and is waiting for the results. The displayed execution time includes both the time spent running the query, and the time spent retrieving the results.
Compressing results - Count has received the result set for the query, and is compressing it.
Downloading results - your browser has been notified that the query results are ready, and has begun downloading them.
Some of these steps may be skipped or display different information in the following cases:
Connecting - for local DuckDB or Python cells, this step also includes the time spent loading the database or Python instance, and waiting for upstream cells to finish executing.
Running query - this step may be skipped if cached results are available for the cell.
Compressing results - this step may be skipped if the query results are small.
When it is important to see the latest data for a cell, it is possible to tell Count to bypass any cache, and send a new SQL query to your database. If caching is enabled, the cached results will be updated at this point.
Clicking the Run cell button above any selected cells will execute those cells. (Note that choosing this option will also re-enable cell execution if it has been disabled previously).
Clicking the Refresh all results button in the canvas query menu will re-execute all canvas cells.
If it is important to reduce load on your database at the expense of result freshness, it is also possible to prevent cells from executing in response to changes:
Click the Disable cell execution button underneath the Run cell menu to prevent that cell executing automatically in the future.
Deselect the Execute cells automatically option in the canvas query menu to prevent all cells in the canvas from executing automatically.
If a cell is prevented from executing automatically, it will show a message with an option to execute the query. If the cell is connected to a BigQuery connection, it will also show an estimate of the amount of data that will be processed by the query:
Count supports query cancellation for the all database connections.
The effectiveness of cancelling a query from Count may depend on the database connection used, and in which step the cancellation was requested:
Connecting - cancelling a query during this step should always succeed, as the query has not started execution yet.
Running query - cancellation from Count is not always guaranteed for some database types, though the cancellation request is always sent to your database.
If your role allows you to edit a canvas, the option to cancel all pending canvas queries will be available in the data menu:
If your role allows you to edit a database connection, you are able to cancel all queries running in all canvases for that connection from the button at the bottom of the connection settings:
As this action can cause errors in many canvases, it must be confirmed from the pop-up dialog:
By default, all cells in Count apply a limit of 10,000 rows in the SQL that is sent to your database to minimise the time spent transferring large result sets.
This default behaviour can be changed from the Row limit settings in the Design sidebar:
Selecting the Unlimited option will remove the 10,000 row limit from the SQL query, and Count will continue to fetch results until they are complete, or their uncompressed size reaches the limit configured for your workspace (this default limit is 128MB).
It is strongly recommended to enable caching of results if using the Unlimited setting, to avoid frequent re-execution of long-running queries.
Browser download limit - set this option to a number to limit the number of rows that are downloaded to your browser, or delete the number to download all results.
Downloading all results to your browser may take a long time if the results are large