
VARIANT columns are convenient but can be expensive for frequently-accessed data. Learn when to flatten JSON and when to keep it semi-structured.

VARIANT columns are convenient but can be expensive for frequently-accessed data. Learn when to flatten JSON and when to keep it semi-structured.
VARIANT Approach:
SELECT
event_data:user_id::INTEGER,
event_data:event_type::VARCHAR
FROM events
WHERE event_data:event_type::VARCHAR = 'purchase';
-- Cost: Scans entire VARIANT column (100GB)
Flattened Approach:
SELECT user_id, event_type
FROM events
WHERE event_type = 'purchase';
-- Cost: Scans only 2 columns (5GB) - 95% reduction
CREATE TABLE api_logs (
log_id INTEGER,
timestamp TIMESTAMP,
-- Flatten commonly-queried fields
user_id INTEGER,
endpoint VARCHAR(200),
response_code INTEGER,
-- Keep full payload for detailed analysis
request_payload VARIANT,
response_payload VARIANT
);
A SaaS company stored 500M event records with 50+ JSON fields. Original: 2TB compressed storage, 100 credits/day query cost, 30-60 seconds average performance.
After flattening top 10 fields (80% of queries): 1.4TB compressed (30% reduction), 15 credits/day (85% reduction), 3-8 seconds average (5-10x faster).
Uncover hidden inefficiencies and start reducing Snowflake spend in minutes no disruption, no risk.