Creating index does not make any change in query plan. - Mailing list pgsql-general

From Deepa
Subject Creating index does not make any change in query plan.
Date
Msg-id Pine.LNX.4.33.0302171248470.9588-100000@ws1154.midascomm.com
Whole thread Raw
Responses Re: Creating index does not make any change in query plan.  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
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.



pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Index not used with IS NULL
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Creating index does not make any change in query plan.