Re: Need help on index!!!

From: Dan Weston <ddweston(at)cinesite(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Need help on index!!!
Date: 2002-06-24 21:43:11
Message-ID: Pine.LNX.4.33.0206241433090.30287-100000@musk.hollywood.cinesite.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try single quotes around 10000:

select * from pmmeasure where dataid = '10000';

This is understood to mean:

select * from pmmeasure where dataid = '10000'::bigint;

Without the quotes this is understood to be

select * from pmmeasure where dataid = ('10000'::int4)::bigint;

which is not what you want anyway.

Dan Weston

On Fri, 21 Jun 2002, Johnson Ma wrote:

> Hi guru
>
> I have a table with 300,000 records. I also created a index on it. But
> the postgresql use sequence scan every time, when i search one record.
> It is so slow. why?
>
> here is create table script
> create table pmmeasure (dataid bigint not null,
> measurenum bigint DEFAULT nextval('measurenum')
> UNIQUE NOT NULL,
> name varchar(100) not null,
> value varchar(100) not null,
> constraint pk_pmmeasure primary key (measurenum),
> constraint fk_pmmeasure_1 foreign key (dataid)
> references pmdata (dataid)
> );
> create index index_pm on pmmeasure (dataid);
>
>
> When I do like
> explain analyze select * from pmmeasure where dataid = 10000;
>
> it shows that postgresql always sequence scan for that record.
>
>
> Thanks a lot.
>
>
> Johnson
>
>
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2002-06-24 21:59:35 Re: initdb
Previous Message Tom Lane 2002-06-24 21:02:37 Re: [HACKERS] pg_restore: [archiver] input file does not appear to be a valid archive