0
0
Azurecloud~5 mins

Creating Azure SQL Database - Performance & Efficiency

Choose your learning style9 modes available
Time Complexity: Creating Azure SQL Database
O(n)
Understanding Time Complexity

When creating an Azure SQL Database, it is important to understand how the time needed grows as we create more databases.

We want to know how the number of steps or calls changes when we increase the number of databases.

Scenario Under Consideration

Analyze the time complexity of the following operation sequence.


# Create a resource group
az group create --name MyResourceGroup --location eastus

# Loop to create multiple SQL servers and databases
for ((i=1; i<=n; i++)); do
  az sql server create --name sqlserver${i} --resource-group MyResourceGroup --location eastus --admin-user admin --admin-password Password123!
  az sql db create --resource-group MyResourceGroup --server sqlserver${i} --name sqldb${i} --service-objective S0
done

This sequence creates n SQL servers and n SQL databases, one database per server.

Identify Repeating Operations

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

  • Primary operation: Creating a SQL server and then creating a SQL database on that server.
  • How many times: Each pair of server and database creation happens n times, once per iteration.
How Execution Grows With Input

As the number of databases n increases, the total number of create operations grows directly with n.

Input Size (n)Approx. Api Calls/Operations
1020 (10 servers + 10 databases)
100200 (100 servers + 100 databases)
10002000 (1000 servers + 1000 databases)

Pattern observation: The number of operations grows linearly as we add more databases and servers.

Final Time Complexity

Time Complexity: O(n)

This means the time to create all databases grows in direct proportion to the number of databases you want to create.

Common Mistake

[X] Wrong: "Creating multiple databases at once takes the same time as creating just one."

[OK] Correct: Each database requires its own creation process, so time adds up with each one.

Interview Connect

Understanding how resource creation scales helps you design efficient cloud deployments and estimate wait times realistically.

Self-Check

What if we created multiple databases on the same SQL server instead of one per server? How would the time complexity change?