Snowflake Performance Tuning for Time-Series Data

Instruction: Propose a set of performance tuning techniques for optimizing the storage and querying of time-series data in Snowflake.

Context: This question challenges the candidate to address the unique challenges of working with time-series data in Snowflake and optimizing performance for such workloads.

Updated

Official answer

Model event time, ingestion time, entity key and a stable event identifier separately. Choose timestamp types/timezone handling deliberately, and define late-arrival, duplicate and correction rules. Time Travel stores eligible historical table states; it is not a replacement for the application's event-history model.

Use selective time predicates with clear boundaries, commonly start-inclusive and end-exclusive. Include the entity dimension when the access pattern needs it. Avoid filtering only by month number when the intended range is a specific year and month.

Inspect partition pruning before adding a clustering key. Naturally ordered ingestion may already help. For large tables, evaluate a suitable date/time expression and entity dimensions against real query patterns; extremely granular timestamps and frequent changes can increase clustering cost.

Create correctly defined aggregates for frequent queries, using supported materialized views or maintained tables as appropriate. Keep counts with sums when recombining averages, and update affected windows when late data arrives. Do not average daily averages without their weights.

Profile actual execution, queueing, scanned partitions and spill. EXPLAIN describes a plan but does not show the runtime evidence of a particular execution. Compare cache conditions and measure ingestion as well as serving cost.

Use a secured clone for testing when useful, but allocate separate compute if workload isolation is required. Clone changes and retained history can add storage. Benchmark realistic ranges and concurrent workloads, and validate missing intervals, time-zone transitions and out-of-order events before accepting a faster query.

Clustering keys, query profile, Time Travel, cloning

Related Questions