OPENING A DISCUSSION THREAD, please give your inputs.
Saying
Hashing works well on the 'equal' queries, while ordered indexing works well better on range queries too.
is acceptable if we know that the query is on the primary key. Isn’t it?
Because suppose if we have multiple rows with $A_{p=c}$, considering that $A_{p}$ is a non-key attribute then this is equivalent to ordering on a non-key attribute i.e. clustered indexing. Now if we have multiple rows with $A_{p=c}$ then it means that it is spread over multiple blocks of data, and in case of hashing this will lead to multiple block access.
Whereas clustered indexing on the non-key attribute $A_{p}$ will have O(log n) complexity. And i would argue in a similar fashion for the range query.
Now coming to this question, we don’t know whether $A_{p}$ is a key or non-key attribute. Therefore considering the worst-case scenario, indexing must be preferred for both the queries because of low average lookup-time.
@Arjun sir, @Sachin Mittal 1 sir, @Deepakk Poonia (Dee) sir,@ dd sir, @ gatecse, @ Shaik Masthan sir please comment if possible.