Creating index does not make any change in query plan.

From: Deepa <kdeepa(at)midascomm(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Creating index does not make any change in query plan.
Date: 2003-02-17 07:36:26
Message-ID: Pine.LNX.4.33.0302171248470.9588-100000@ws1154.midascomm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-02-17 07:48:22 Re: Postgres Databases growing without much reason
Previous Message Martijn van Oosterhout 2003-02-17 07:29:07 Re: Creating index does not make any change in query plan.