Re: Index usage question

From: Ryan Mahoney <ryan(at)paymentalliance(dot)net>
To: "Norbert Zoltan Toth" <Norbert(dot)Zoltan(dot)Toth(at)cern(dot)ch>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Index usage question
Date: 2001-09-04 23:34:25
Message-ID: 5.0.2.1.0.20010904193051.03c75c60@paymentalliance.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What does your data look like? If you have a lot of duplicate id's, a
sequential scan may be better than an index scan.
If you are not sure if this is the case, try:

SELECT id, count(*) AS count FROM test GROUP BY id ORDER BY count DESC
LIMIT 50;

This should show you the top 50 most duplicated records in your table.

-r

At 08:52 PM 9/4/01 +0200, Norbert Zoltan Toth wrote:

>I have experienced the following problem, maybe they are related:
>
>I create a table with
> create table test (id int, name char(10));
>
>then I create an index on it with
> create index test_idx on test (id);
>
>After populating my table, the query
> select id from test where id='1';
>
>uses index scan.
>
>However when I only create the index AFTER inserting rows into the table,
>the index is not being used for the evaluation,
>even if I run vacuum / vaccum analyze on test;
>
>I would also appreciate some help with this.
>
>Thank you,
>Norbert
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://www.postgresql.org/search.mpl
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com)
>Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01

Attachment Content-Type Size
unknown_filename text/plain 166 bytes

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Asher 2001-09-04 23:37:48 recovering a control file from a shutdown database....
Previous Message Bruce Momjian 2001-09-04 23:14:40 Re: embedded SQL cursos declare fails