0
0
Snowflakecloud~5 mins

Reader accounts for non-Snowflake users - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Reader accounts for non-Snowflake users
O(n)
Understanding Time Complexity

We want to understand how the work grows when using reader accounts for users outside Snowflake.

Specifically, how does the number of operations change as more external users access data?

Scenario Under Consideration

Analyze the time complexity of this sequence creating and using reader accounts.


CREATE READER ACCOUNT reader_acc;
GRANT USAGE ON DATABASE sales_db TO READER ACCOUNT reader_acc;
-- External user connects using reader_acc
SELECT * FROM sales_db.public.orders;
-- Repeat for multiple external users

This sequence sets up a reader account and external users query data through it.

Identify Repeating Operations

Look at what happens repeatedly when many external users access data.

  • Primary operation: External queries through the reader account.
  • How many times: Once per external user query.
How Execution Grows With Input

As more external users query data, the number of queries grows directly with users.

Input Size (n)Approx. API Calls/Operations
1010 queries through reader account
100100 queries through reader account
10001000 queries through reader account

Pattern observation: The work grows in a straight line as users increase.

Final Time Complexity

Time Complexity: O(n)

This means the number of operations grows directly with the number of external users querying data.

Common Mistake

[X] Wrong: "Adding more external users does not increase query operations because they share the same reader account."

[OK] Correct: Each external user runs their own queries, so the total queries increase with users, even if the reader account is shared.

Interview Connect

Understanding how external user queries scale helps you design data sharing solutions that handle growth smoothly.

Self-Check

"What if each external user had their own reader account instead of sharing one? How would the time complexity change?"