Search time complexity of this sql query

Sneha

This table provides information about real estates. The column “Type” contains either the value “Apartment”, “House”, “Townhouse” or “Villa”. The number of entries for each type is roughly 25% of the total number of entries in the table.

Table Name Column Name Data Type RealEstate ID DEC(10) Type VARCHAR(40) Price DEC(10,2) Size DEC(4) A typical query asks for all real estates of a given type: select ID from RealEstate where Type = ′House’ Two indexes were defined for this table. The first index was defined for the column ′ID′ and the second index was defined for the column ′Type′. what will be the time complexity of this query relative to the number of entries n and the size of the result set m??

the time complexity will be O (log(n)+m) or O(n)??

peter.petrov

This is very roughly speaking and in a way a speculation:

The complexity should be O(m) because due to the indexes present,
the DB engine can find/locate the records matching Type = 'House'
in constant time. So all that is taking time here is to process the
matching records whose count is m (e.g. to read them and to return
them to the caller). So the complexity is O(m) because the processing
is proportional to the count of the records returned.

But when viewed at a lower level, I guess it all depends on many other things too:
if your index is well-maintained (not fragmented), if the records are well-situated
on the disk (e.g. sequentially), etc, etc. So it is hard to give a direct/simple
big O formula.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NSDictionary Search Time Complexity

From Dev

Time Complexity of Binary Search?

From Dev

Time complexity of range query

From Java

Complexity and Time consumption while executing the sql query in DB2

From Dev

SQL offset time complexity?

From Dev

Reducing time complexity of firebase query

From Dev

Breadth First Search time complexity analysis

From Java

What is the time-complexity in a binary search?

From Dev

Time complexity of Uniform-cost search

From Dev

Running time complexity for binary search tree

From Dev

Time and Space Complexity for Breadth First Search

From Dev

Time complexity of deletion in binary search tree

From Dev

Time/Space Complexity of Depth First Search

From Dev

GATE 2008: Time Complexity of Binary Search Tree

From Dev

Time and Space Complexity for Breadth First Search

From Dev

Time complexity of deletion in binary search tree

From Dev

Time complexity in search of a list within a tree

From Dev

What would be time Complexity of binary search algorithm?

From Dev

Time complexity of query of MongoDB array vs object

From Dev

SQL query composition search

From Dev

Rails search SQL query

From Dev

Sql Query For Search Not Working

From Dev

SQL query for book search

From Dev

Time complexity for rebuilding binary search tree / quadtree / octtree?

From Dev

Time Complexity of breadth first search with adjacency matrix representation?

From Dev

How to handle the time complexity for permutation of strings during anagrams search?

From Dev

Time complexity of search operation on hash tables using separate chaining

From Dev

Why does assignment in a binary search algorithm not add to the time complexity?

From Dev

'if not in' time complexity

Related Related

HotTag

Archive