## 4.4 Result Cache
The static result cache and the dynamic result cache are configurable applications of caching query results to gain performance benefits.
Caching is used widely in SAP HANA as a strategy to improve performance by re-using queried data rather than re-reading and processing the data every time it is requested. The static result cache (sometimes referred to as cached views) and the dynamic result cache are applications of this. The static result cache is created for a specific view and remains valid for the duration of a user-defined retention period. The dynamic result cache is similar but does not have a retention period; it guarantees transactional consistency by maintaining delta records of all changes applied to the underlying table.
The following table gives a comparative overview of essential details of the static and dynamic result cache features, these are described in detail in the subsections which follow:
| Feature                         | Static Result Cache                                                                                                                                                                                                   | Dynamic Result Cache                                                                                                                                                                                                                         |
|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Target Scenario                 | Scalability enhancement for query on complex view (usually top-level view) from an application which can accept stale data.                                                                                           | Scalability enhancement for heavy aggregation workload on big tables which are frequently updated (for example ACDOCA).                                                                                                                      |
| Query result                    | Stale data                                                                                                                                                                                                            | Non-Stale data                                                                                                                                                                                                                               |
| Scope                           | Target objects : SQL View, User-defined table function (w/o imperative logic), Calculation view with some limitation. Aggregation types : SUM, MIN, MAX, COUNT.                                                       | Target objects : SQL Views on the aggregation of a single column table. Aggregation types : SUM, COUNT, AVG - fully supported. MIN, MAX- partially supported for insert only table.                                                          |
| Cache Maintenance               | Whenever the cache period becomes older than the retention period then the cache is fully refreshed.                                                                                                                  | At each query execution: -If updated records are identifiable then the cache is incrementally updated with updated records. -If no update is identifiable (due toMVCC garbage collection) then the cache is fully refreshed.                 |
| Implicit view matching          | Not supported                                                                                                                                                                                                         | Supported with hint / configuration.                                                                                                                                                                                                         |
| Adoption effort: defining cache | Usually static result cache is enabled on existing CDS view or calculation view. In the case of a CDS view without aggregation the result cache should be defined with expected aggregation type from target queries. | If the target aggregation is already defined as a view, dynamic result can be enabled on the existing view (explicit usage). Otherwise, a new view definition is required and dynamic result cache can be used with implicit view matching . |
| Feature                                   | Static Result Cache                                                                                  | Dynamic Result Cache                                                                                                                                                |
|-------------------------------------------|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Adoption effort: enable cache utilization | A hint is required to exploit static result cache to make user intention on stale data access clear. | Dynamic result cache is utilized by default even without a hint (but hint or configuration is required for enabling implicit view matching in the current release.) |