Performace of SELECT query based on primary key vs. indexed column I have a scenario where a row in a table can be obtained by using either primary key or another column which is indexed:
SELECT * FROM table_name WHERE primary_key = ?

vs.
SELECT * FROM table_name WHERE another_column = ?

another_column has unique values and has index created on it.
I am using Postgres, and on doing explain analyze on both SELECTs, they resulted in almost same execution time.
So, my question is, generally, is the performance for both the queries same or is one query better than the other? And why?
In PostgreSQL there is no difference between a primary key index and other indexes, so that does not surprise me.
The only slight difference could be caused by the size of the indexed data (wider values cause deeper indexes, so more blocks have to be traversed) or the speed of the comparison function. In most real world cases, the difference will be hard to measure.