December 23, 2024

Business Post

Business Post is Everything you Need

Is the time complexity of querying an indexed column O(1)?

1 min read

Let’s suppose that table A has a column named X which is numeric and indexed.

If the query is something like:

find all rows where X is greater than some value

Is the time complexity of retrieving the result O(1)?

In other words, it does not matter whether table A has 1 million rows versus 10 billion rows?

Question 2:

Let’s suppose that table A has another numeric column Y which is numeric and indexed.

If the query is now:

find all rows where 
X is greater than some value
AND
Y is smaller than some value

Would this query take twice as long as the first query?