Re: The type int8 and the use of indexes

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: nelson(at)radix(dot)com(dot)br
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: The type int8 and the use of indexes
Date: 2001-01-25 23:14:53
Message-ID: Pine.BSF.4.21.0101251509180.86621-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 25 Jan 2001 nelson(at)radix(dot)com(dot)br wrote:

>
> Hi,
>
> I realized that PostgreSQL (7.0.3) optimizer doesnt use indexes in a query
> like "select * from my table where pk=1", where the field pk is of
> type int8.
> I changed the type to int4, and now it uses the index (a lot faster). I also
> tryed changing the type to numeric, with the same results.
> Why does it happen? Is there something special with type int8 ???

Forgot about that. :(
The reason is that the 1 is being treated as an int4 and it's not smart
enough to realize it can use the int8 index for the search.

select * from table where pk=1::int8 should use the index if pk is an
int8 column.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Leibel 2001-01-25 23:14:58 timestamp calculations
Previous Message nelson 2001-01-25 22:11:53 The type int8 and the use of indexes