Re: Indexes not working, please help. - Mailing list pgsql-general

From Antonis Antoniou
Subject Re: Indexes not working, please help.
Date
Msg-id 3D254393.9420BD20@albourne.com
Whole thread Raw
In response to Indexes not working, please help.  (Ricardo Ryoiti Sugawara Junior <suga@netbsd.com.br>)
Responses Re: Indexes not working, please help.
List pgsql-general
Ricardo Ryoiti Sugawara Junior wrote:

>         Hi there.
>
>         The table medidas has the following structure:
>
>                                         Table "medidas"
>    Column   |            Type             |                      Modifiers
> ------------+-----------------------------+-----------------------------------------------------
>  cod        | bigint                      | not null default
> nextval('"medidas_cod_seq"'::text)
>  cod_ponto  | bigint                      |
>  data_hora  | timestamp without time zone |
>  valor      | smallint                    |
>  tipo_ponto | bytea                       |
>  unidade    | bytea                       |
> Indexes: teste
> Primary key: medidas_pkey
>
>         I populated it with 8859000 entries using many "100 inserts"
> blocks transactions. Inserting data on the table is no problem.
>         Althought I created the "teste" index ( create index teste on
> medidas (cod) ), vacuumed and analyzed the database, pgsql still doesn't
> use indexes.
>
> explain select * from medidas where cod = 1231232;
> ---
> NOTICE:  QUERY PLAN:
>
> Seq Scan on medidas  (cost=0.00..197590.50 rows=1 width=36)
> ---
>
>         I've read all the documentation I found, but I couldn't figure out
> what's happening. Setting "enable_seqscan" to false doesn't help either.
>         This machine I'm working on won't be the production server, but
> it's not that slow machine (P3 1GHz, 384MB, ATA 100) and without indexes
> working, that select mentioned above takes almost 60 seconds to run...
>
>

Hi,
Is your index on the attribute cod? If not then try this:
CREATE INDEX teste ON medidas (cod);

Thanks
Antonis




pgsql-general by date:

Previous
From: Ricardo Junior
Date:
Subject: Re: Indexes not working, please help.
Next
From: Curt Sampson
Date:
Subject: Re: I am being interviewed by OReilly