Why does it not use the index?

Поиск
Список
Период
Сортировка
От Philip Greer
Тема Why does it not use the index?
Дата
Msg-id 20030721170607.GA18568@tildesoftware.com
обсуждение исходный текст
Ответы Re: Why does it not use the index?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
This one is irritating. Here's some psql output:

================================================================================
dumps=# \d fal_profdel
               Table "fal_profdel"
 Attribute |           Type           | Modifier
-----------+--------------------------+----------
 sid       | character(4)             | not null
 card_num  | character(19)            | not null
 date_del  | timestamp with time zone |
 filename  | character varying(30)    |
Indices: fal_prfdel_cn,
         fal_prfdel_date,
         fal_prfdel_pk

dumps=# \d fal_prfdel_cn
   Index "fal_prfdel_cn"
 Attribute |     Type
-----------+---------------
 card_num  | character(19)
unique btree

dumps=# explain select card_num from fal_profdel where card_num = 'removed_for_privacy';
NOTICE:  QUERY PLAN:

Seq Scan on fal_profdel  (cost=0.00..120546.39 rows=46649 width=12)

EXPLAIN
================================================================================

Now, why the heck is the select query not using the index? I've tried it by having an exact 19 character card_num as
well- still explains as a 'Seq Scan' (tablespace scan) - and each query takes up to 37 seconds (thus confirming that it
isindeed doing scans and not using the index). 

I've tried dropping and re-creating the indexes, still it explains as tablespace scans.

I am running postgresql 7.1.3 - a bit old, I know, but I have had no reason to upgrade just yet.

By the way, the fal_profdel table has 4,664,867 rows in it currently - thus I really don't want full table scans!

--
-----------------------------------------------------------------------------
PG..                                                 philip@tildesoftware.com
Law of probable dispersal: Whatever it is that hits the fan will not be
evenly distributed.

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: LinkServer
Следующее
От: Chris Gamache
Дата:
Сообщение: pg_dump dies on a renamed sequence... (7.2)