Google Keyword Planner basics in SEO Fundamentals - Time & Space Complexity
When using Google Keyword Planner, it is helpful to understand how the tool handles data as you search for keywords.
We want to know how the time it takes to get results changes when we look up more keywords or add filters.
Analyze the time complexity of the following keyword search process.
function getKeywordIdeas(keywords) {
let results = [];
for (let keyword of keywords) {
let ideas = fetchIdeasFromAPI(keyword);
results.push(...ideas);
}
return results;
}
This code fetches keyword ideas for each keyword in the list by calling the API once per keyword.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each keyword and calling the API.
- How many times: Once for each keyword in the input list.
As you add more keywords, the number of API calls grows directly with the number of keywords.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 API calls |
| 100 | 100 API calls |
| 1000 | 1000 API calls |
Pattern observation: The time grows in a straight line as you add more keywords.
Time Complexity: O(n)
This means the time to get keyword ideas increases directly with the number of keywords you search.
[X] Wrong: "Adding more keywords won't affect the time much because the API is fast."
[OK] Correct: Even if the API is fast, each keyword requires a separate call, so more keywords mean more calls and more total time.
Understanding how time grows with input size helps you explain how tools like Google Keyword Planner handle large searches efficiently.
"What if we batch multiple keywords into a single API call? How would the time complexity change?"