Creating index does not make any change in query plan.

Поиск
Список
Период
Сортировка
От Deepa
Тема Creating index does not make any change in query plan.
Дата
Msg-id Pine.LNX.4.33.0302171248470.9588-100000@ws1154.midascomm.com
обсуждение исходный текст
Ответы Re: Creating index does not make any change in query plan.
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Index not used with IS NULL
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Creating index does not make any change in query plan.