Projections in Snowflake for performance
Snowflake offers the concept of MVs for optimizing different access patterns. MVs allow disconnecting the table design from evolving access paths. This recipe shall provide you with guidance on using MVs, their limitations, and their implications.
Getting ready
This recipe shows how Snowflake MVs can be constructed from a table and how query latency can be reduced. Note that these steps can be run in either the Snowflake web UI or the SnowSQL command-line client.
How to do it…
Let's start by creating a table in a database, followed by generating a large dataset to demonstrate how MVs improve efficiency. The steps for this recipe are as follows:
- We will start by creating a new database:
CREATE DATABASE C6_R5;
The database should be created successfully.
- Moreover, we shall execute a configuration change for the following steps so that Snowflake does not use caching:
ALTER SESSION SET USE_CACHED_RESULT=FALSE;
...