Re: Using indices with long unique IDs.

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>
Cc: Sergey Olefir <so3lv(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Using indices with long unique IDs.
Date: 2004-01-09 12:25:24
Message-ID: 20040109122524.GA16604@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 09, 2004 at 04:11:08AM -0600, D. Dante Lorenso wrote:
> Sergey Olefir wrote:
>
> >So the logical choice would be int8, right? Unfortunately quite wrong.
> >Statement of the form: "SELECT * FROM table WHERE id=1"
> >will never use index for id (assumming id is int8) since '1' is of type
> >int4. This is confirmed both by documentation and SQL EXPLAIN (after set
> >enable_seqscan TO 'off').

I think you can use WHERE id=cast(1 AS bigint)

> Well, that just plain sucks. That means I've gotta go back and
> add casts to all my queries?
>
> Tell me it isn't so!

Yeah, it is :-( AFAIU it is fixed in the current development version,
but who knows if it will be done in time before you tables grow too big ...

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Porque francamente, si para saber manejarse a uno mismo hubiera que
rendir examen... ¿Quién es el machito que tendría carnet?" (Mafalda)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannu Krosing 2004-01-09 13:31:50 Re: Postgres + Xapian (was Re: fulltext searching via a
Previous Message CoL 2004-01-09 12:19:02 Re: Using indices with long unique IDs.