pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Use of indexes
2+ messages / 2 participants
[nested] [flat]

* Use of indexes
@ 2002-04-26 07:09  Andre Schubert <andre.schubert@km3.de>
  0 siblings, 1 reply; 2+ messages in thread

From: Andre Schubert @ 2002-04-26 07:09 UTC (permalink / raw)
  To: pgsql-sql

Hi all,

i have a litte problem using indexes with datatypes int and int8.

i have a table

test:
	id1 int,
        id2 int8

if have to indexes:

index_test_1:
--------+---------
 id1    | integer
btree

index_test_2:
--------+--------
 id2    | bigint
btree

If i do any explains i got the following:

db_nmkm3=# explain select * from test where id1=1;
Index Scan using index_test_1 on test  (cost=0.00..3.01 rows=1 width=12)

db_nmkm3=# explain select * from test where id2=1;
Seq Scan on test  (cost=0.00..20.55 rows=1 width=12)

db_nmkm3=# explain select * from test where id2=1::int8;
Index Scan using index_test_2 on test  (cost=0.00..3.01 rows=1 width=12)

Can somebody explain me whats wrong with me or my indexes?

thanks in advance



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Use of indexes
@ 2002-04-26 07:30  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  parent: Andre Schubert <andre.schubert@km3.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Christopher Kings-Lynne @ 2002-04-26 07:30 UTC (permalink / raw)
  To: Andre Schubert <andre.schubert@km3.de>; pgsql-sql

> If i do any explains i got the following:
>
> db_nmkm3=# explain select * from test where id1=1;
> Index Scan using index_test_1 on test  (cost=0.00..3.01 rows=1 width=12)
>
> db_nmkm3=# explain select * from test where id2=1;
> Seq Scan on test  (cost=0.00..20.55 rows=1 width=12)
>
> db_nmkm3=# explain select * from test where id2=1::int8;
> Index Scan using index_test_2 on test  (cost=0.00..3.01 rows=1 width=12)
>
> Can somebody explain me whats wrong with me or my indexes?

Nothing's wrong with your indexes - it's a known limitation of Postgres's
type system.

You just have to use the "::int8" cast and it all works fine.

Chris




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-04-26 07:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-04-26 07:09 Use of indexes Andre Schubert <andre.schubert@km3.de>
2002-04-26 07:30 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox