Why data sharing eliminates data copies in Snowflake - Performance Analysis
We want to understand how the work grows when using data sharing instead of copying data.
Specifically, how many operations happen as data size grows when sharing data.
Analyze the time complexity of sharing data instead of copying it.
-- Create a share
CREATE SHARE my_share;
-- Add a database to the share
ALTER SHARE my_share ADD DATABASE my_database;
-- Consumer creates a database from the share
CREATE DATABASE shared_db FROM SHARE provider_account.my_share;
This sequence shares a database without copying data, allowing access without duplication.
Look at what happens repeatedly when sharing data.
- Primary operation: Granting access to data via share metadata.
- How many times: Once per share setup, regardless of data size.
Sharing data does not copy data, so operations stay almost the same as data grows.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 3 (create share, add database, create consumer DB) |
| 100 | 3 (same operations, no extra copies) |
| 1000 | 3 (still just setup calls, no data duplication) |
Pattern observation: The number of operations stays constant, not growing with data size.
Time Complexity: O(1)
This means the work to share data stays the same no matter how big the data is.
[X] Wrong: "Sharing data copies all the data behind the scenes."
[OK] Correct: Sharing only grants access pointers, so no data is duplicated or copied.
Understanding how sharing avoids copying helps you explain efficient data access in cloud systems.
"What if data sharing required copying data to the consumer account? How would the time complexity change?"
Practice
Solution
Step 1: Understand data sharing concept
Data sharing allows multiple users or accounts to access the same dataset without creating separate copies.Step 2: Identify how data copies are avoided
Since users query the shared data directly, no extra storage is used for duplicates.Final Answer:
Because users access the same data directly without duplicating it -> Option BQuick Check:
Data sharing = no data copies [OK]
- Thinking data is copied for each user
- Confusing encryption with data copying
- Assuming data is deleted after sharing
Solution
Step 1: Identify Snowflake sharing object
Snowflake uses a 'secure share' object to share data securely without copying.Step 2: Differentiate from other objects
Database clones create copies; warehouses process queries; stages store files. Only secure shares share data without copies.Final Answer:
Secure share -> Option AQuick Check:
Secure share = data sharing without copies [OK]
- Confusing clones with shares
- Thinking warehouses share data
- Mixing stages with data sharing
Solution
Step 1: Understand shared table access
When Account B queries a shared table, it accesses the original data stored in Account A's storage.Step 2: Confirm no data copying occurs
Snowflake's sharing avoids copying by letting Account B query data directly from Account A's storage.Final Answer:
Account B queries the original table in Account A's storage -> Option DQuick Check:
Shared data queried from original storage [OK]
- Assuming data is copied to Account B
- Thinking Account B must copy before querying
- Believing Account B cannot query shared data
Solution
Step 1: Understand difference between clone and share
A clone creates a full copy of the data, which uses additional storage space.Step 2: Identify the problem with cloning for sharing
Cloning duplicates data, defeating the purpose of sharing without copies.Final Answer:
The clone creates a full copy, using extra storage -> Option CQuick Check:
Clone duplicates data, uses storage [OK]
- Thinking clone shares data without copying
- Believing clone cannot be queried
- Assuming clone deletes original data
Solution
Step 1: Understand data consistency in sharing
Snowflake shares data by allowing all consumers to query the same live data in the provider's account.Step 2: Explain how copies affect consistency
Copies can become outdated; sharing live data avoids this problem and keeps data consistent.Step 3: Confirm no copies are made
Since no copies are created, all consumers see the same up-to-date data instantly.Final Answer:
By letting all consumers query the same live data in the provider's account -> Option AQuick Check:
Live shared data keeps consistency [OK]
- Thinking data is copied and synced
- Assuming data is exported to files
- Believing only one consumer can access at a time
Ready to prove it?
Pass the test and this pattern moves unknown
