Cache Cheatsheet
Cache Cheatsheet
CACHE
Sebastian Flak
There are 3 types of cache:
VIRTUAL WAREHOUSE
QUERY RESULT
METADATA
Sebastian Flak
Virtual Warehouse cache
Also known as main or compute cache.
When queries are run, Snowflake uses the compute
resources of virtual warehouses to perform the
operations.
Each virtual warehouse has its own locally attached
cache for data it accesses.
If subsequent queries can be served by the data in the
warehouse's cache, they will be executed faster
because they avoid accessing data storage.
The warehouse cache is particularly effective during
sessions where multiple queries are run that access the
same data sets.
Sebastian Flak
Virtual Warehouse cache
No cache With cache
Sebastian Flak
Virtual Warehouse cache
If the virtual warehouse is suspended, the cache
is lost!
Find balance between suspending warehouse
“too early” and try to keep it long enough to use
cache.
Monitor your usage and then decide when to
turn it off.
You can do it with:
Sebastian Flak
Query Result cache
Snowflake automatically caches the results of
every query for 24 hours.
If the same query is executed again and the
underlying data has not changed, Snowflake
retrieves the result from the cache rather than
re-executing the query against the database.
“All or nothing“ mechanism. You either use it or
not - there is no partial benefit.
Work perfectly for repeated queries, such as
those often run in business intelligence tools.
Sebastian Flak
Query Result cache
Before After
Sebastian Flak
Query Result cache
Sebastian Flak
Metadata cache
Sebastian Flak
Metadata cache
Total number of rows example:
Sebastian Flak
Metadata cache
Sebastian Flak
Did you like it?
Repost
Find me on YouTube
Sebastian Flak