Hi,
When I do explain on 'activealarms' table while selecting
a row with primary key (AFAIK while creating primary key, an index will be
created on that column), the following result occurs.
EXPLAIN SELECT * from activealarms where recordid = 2;
NOTICE: QUERY PLAN:
Seq Scan on activealarms (cost=0.00..7122.86 rows=1 width=189)
EXPLAIN
Here 'recordid' is the primary key whose datatype is bigint.
The same procedure I followed for a non primary key value, which
retrieves 10 rows. The result is given below.
EXPLAIN SELECT * from activealarms where agentid = 2;
NOTICE: QUERY PLAN:
Seq Scan on activealarms (cost=0.00..7122.86 rows=10 width=189)
EXPLAIN
Here 'agentid' is the non primary key whose datatype is also bigint.
I cannot see difference in Query plan for a select query using primary key
and non primary key value. Then what could be the use of a field to be
used as a primary key.
--
regards,
Deepa. K
--
Engineer,
Network Management System,
Midas Communication Technologies private Ltd,
Chennai.