Snowflake - SnowPro Core Study Guide

    4: Performance Optimization, Querying, and Transformation

    This chapter covers how to diagnose slow Snowflake queries through Query Profile signals and ACCOUNT_USAGE views, then apply the right optimization lever from query acceleration service, search optimization service, clustering keys, or materialized views. It closes with caching mechanics across the three cache tiers and the SQL techniques for transforming structured, semi-structured, and unstructured data with aggregate and window functions.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Evaluate query performance using Query Profile, query insights, and ACCOUNT_USAGE views, and identify bytes spilled, inefficient pruning, exploding joins, and queuing.
    • Optimize query performance with the query acceleration service, search optimization service, clustering keys, and materialized views.
    • Use Snowflake caching across the query result cache, metadata cache, and warehouse cache.
    • Perform data transformation techniques on structured, semi-structured, and unstructured data using aggregate functions, window functions, and SQL optimization patterns.

    Executive Summary

    • Query performance investigation in Snowflake starts at Query Profile and finishes at the ACCOUNT_USAGE views; the four canonical bad signals are bytes spilled to storage, inefficient pruning, exploding joins, and queuing.
    • The optimization toolbox is layered: pick the lever that matches the bottleneck (query acceleration service for skewed scans, search optimization service for selective point lookups, clustering keys for range scans on large tables, materialized views for repeated aggregations).
    • The three caches operate at different layers of the architecture: query result cache lives in Cloud Services, metadata cache holds object statistics for plan generation, and warehouse cache is the local SSD on each compute node.
    • Transformation work in Snowflake spans relational SQL, semi-structured VARIANT traversal with FLATTEN, and unstructured file handling through stages and directory tables; aggregate and window functions are the workhorses for analytical reshaping.

    Assumptions

    • The reader has six or more months of hands-on Snowflake practice and has built and operated production workloads.
    • All examples assume the default time zone is UTC and that the account holds at least Enterprise Edition unless a feature explicitly requires Business Critical or higher.
    • Numeric quotas reflect the latest published values in the Snowflake documentation; verify against the official documentation before applying to a production workload.
    • Service names follow the official capitalization: Snowflake Cortex, Snowpark, Snowsight, Snowpark Optimized, Snowpark Container Services, Snowflake Notebooks, Search Optimization Service, Query Acceleration Service.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account
    5. Free with account