RE: primary key scans in sequence - Mailing list pgsql-sql

From Stephan Szabo
Subject RE: primary key scans in sequence
Date
Msg-id Pine.BSF.4.21.0105310834480.11460-100000@megazone23.bigpanda.com
Whole thread Raw
In response to RE: primary key scans in sequence  ("Koen Antonissen" <Koen@Cee-Kay.net>)
List pgsql-sql
It really depends on the number of rows.  If the number of
rows in the tables are small or the number of rows returned is
a reasonable percentage, the index scan is currently more expensive.

What does (for example) select count(*) from classes; give?


On Thu, 31 May 2001, Koen Antonissen wrote:

> actually the serials are declared int4 (integer),
> I tried to use your work around anyway, but it didn't work...:
> 
> dsc_competition=# \d classes 
>                              Table "classes"
>  Attribute  |  Type   |                     Modifier
> 
> ------------+---------+-------------------------------------------------
> -
>  id         | integer | not null default nextval('classes_id_seq'::text)
>  name       | text    | not null
>  definition | text    | 
>  active     | boolean | default 't'::bool
> Indices: classes_pkey,
>          index_classes_name,
>          unq_classes_name
> 
> dsc_competition=# explain select * from classes where id = int8(4);
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on classes  (cost=0.00..1.07 rows=1 width=29)
> 
> EXPLAIN
> dsc_competition=# explain select * from classes where id = int4(4);
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on classes  (cost=0.00..1.07 rows=1 width=29)
> 
> EXPLAIN
> dsc_competition=# explain select * from classes where id = int2(4);
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on classes  (cost=0.00..1.07 rows=1 width=29)
> 
> EXPLAIN
> 
> 
> 
> Thing I descovered after i posted to the group was that after creating
> the scheme again, the indexes are used! after vacuum (analyze) the use
> of indexes was gone again on certain tables...
> 
> Any other suggestions?



pgsql-sql by date:

Previous
From: Brian Powell
Date:
Subject: 7.1.1 Lock Problems on Views
Next
From: "Josh Berkus"
Date:
Subject: Re: rowset Return from postgresql