# (Appendix) Query Execution and Cache

In various scenes, we create and utilize caches with each query execution to prevent redundant background jobs.

This helps in reducing the amount of data scanned and in obtaining execution results faster.

## **Query Execution**

Queries are executed in the following features:

* [Doc Page](https://docs.codatum.com/data-exploration/notebook/doc-page)
  * Run all, Run all with fresh data
  * [SQL Block](https://docs.codatum.com/data-exploration/notebook/sql-block)
    * Run, Run with fresh data
* [Grid Page](https://docs.codatum.com/data-exploration/notebook/grid-page)
  * Run all, Run all with fresh data
* [Report](https://docs.codatum.com/sharing/report) & [Signed Embed](https://docs.codatum.com/sharing/signed-embed)
  * Refresh
  * Automatically run
* Query
  * Run
* Table preview features across various functions

## **Warehouse-side Cache**

If the SQL statement does not change, the warehouse-side cache (e.g., [cached query results in BigQuery](https://cloud.google.com/bigquery/docs/cached-results)) is used. When using SQL Chain, intermediate SQL results are automatically rewritten to use the cache table.

## **Small Cache for Notebooks and Reports**

* SQL results of up to 1000 rows are stored as a cache with the notebook. Charts and other components can utilize these results up to 1000 rows.
* If the same SQL is executed again within 24 hours, the saved display-ready data is retrieved and shown without running a new job.
  * To execute with a new job, select `Run all with fresh data` to update the results.
* Report cache expiration time can be changed from the report settings.

{% hint style="info" %}
Table preview features retrieve data each time they are viewed, so cache is not utilized.
{% endhint %}
