select query not using index

Поиск
Список
Период
Сортировка
От
Тема select query not using index
Дата
Msg-id 200612021105.kB2B5lWY017777@mail009.ownmail.com
обсуждение исходный текст
Ответы Re: select query not using index  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: select query not using index  ("hubert depesz lubaczewski" <depesz@gmail.com>)
Список pgsql-general
Dear Friends,
I have a table as
 \d userpref;
                               Table "public.userpref"
   Column    |          Type          |                   Modifiers
-------------+------------------------+------------------------------------------------
 username    | character varying(101) | not null
 email       | character varying(255) | not null
 context     | character varying(32)  | not null default 'from_box'::character varying
 Indexes:
    "userpref_user_idx" btree (username)
Foreign-key constraints:
    "userpref_username_fkey" FOREIGN KEY (username, email) REFERENCES users(username, email)

The index was created before the table was populated. There are 3 rows in the table for 3 different users. Now when I
doa  

EXPLAIN  SELECT * from userpref where username = 'vivek';
                        QUERY PLAN
-----------------------------------------------------------
 Seq Scan on userpref  (cost=0.00..1.26 rows=1 width=349)
   Filter: ((username)::text = 'vivek'::text)

EXPLAIN ANALYZE  SELECT * from userpref where username = 'vivek';
                                             QUERY PLAN
----------------------------------------------------------------------------------------------------
 Seq Scan on userpref  (cost=0.00..1.04 rows=1 width=70) (actual time=0.060..0.071 rows=1 loops=1)
   Filter: ((username)::text = 'vivek'::text)
 Total runtime: 0.216 ms
(3 rows)


It shows seq scan . It is not using the index perhaps. But I fail to understand why does it not use the index created?
Ihave tried vacuuming the database, reindexing the table, running analyze command.  
Can anyone tell me what am I doing wrong?






With warm regards.

Vivek J. Joshi.

vivek@staff.ownmail.com
Trikon Electronics Pvt. Ltd.

All science is either physics or stamp collecting.
                -- Ernest Rutherford




В списке pgsql-general по дате отправления:

Предыдущее
От: "hubert depesz lubaczewski"
Дата:
Сообщение: Re: postgresql 8.2 rc1 - crash
Следующее
От: "Gregory S. Williamson"
Дата:
Сообщение: Re: select query not using index