page46
27
1
Exists in
Cache?
2
3
4
5
Result Cache
Plan /
Opmize
SQL
Query
Ingeson
Warehouse
Results
Figure 2-1.
Query lifecycle
Query Overview
I will now explain at a high level the steps highlighted within Figure 2-1.
1.
Snowflake ingests a SQL statement; you do not specify the source
as there are many and varied inbound connection paths.
2.
If the query exactly matches a previously run query and the
data has not changed, then the result set is returned from the
result cache.
3.
Otherwise, the query planner and optimizer use metadata to work
out the exact data set and lowest cost access path to satisfy the
SQL query.
4.
The warehouse identifies and retrieves the exact data from
the local or remote disk and then returns the data to the cloud
services.
5.
The result set is returned to the client and stored in the result
cache for reuse.
Chapter 2
the Query Optimizer