0
0
Supabasecloud~5 mins

Custom domains in Supabase - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Custom domains
O(n)
Understanding Time Complexity

When setting up custom domains in Supabase, it's important to understand how the time to complete the setup grows as you add more domains.

We want to know how the number of domains affects the total operations needed to configure them.

Scenario Under Consideration

Analyze the time complexity of adding multiple custom domains to a Supabase project.


// Example: Adding multiple custom domains
const domains = ['example1.com', 'example2.com', 'example3.com'];
for (const domain of domains) {
  await supabase.functions.createCustomDomain({
    domain: domain,
    projectId: 'project-id'
  });
}
    

This code adds each domain one by one to the Supabase project by calling the API for each domain.

Identify Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: API call to create a custom domain for each domain.
  • How many times: Once per domain added.
How Execution Grows With Input

Each new domain requires one API call, so the total calls grow directly with the number of domains.

Input Size (n)Approx. API Calls/Operations
1010 API calls
100100 API calls
10001000 API calls

Pattern observation: The number of operations grows in a straight line as you add more domains.

Final Time Complexity

Time Complexity: O(n)

This means the time to add custom domains grows directly in proportion to how many domains you add.

Common Mistake

[X] Wrong: "Adding multiple domains happens all at once, so time stays the same no matter how many domains."

[OK] Correct: Each domain requires a separate API call, so the total time increases with each additional domain.

Interview Connect

Understanding how operations scale with input size helps you design efficient cloud setups and explain your reasoning clearly in interviews.

Self-Check

"What if the API allowed batch adding of multiple domains in one call? How would the time complexity change?"