Re: Tip ? - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: Tip ?
Date
Msg-id 1116959646.31821.278.camel@state.g2switchworks.com
Whole thread Raw
In response to Tip ?  (Alain <alainm@pobox.com>)
List pgsql-sql
On Tue, 2005-05-24 at 13:26, Alain wrote:
> This tip was at the end of a message (from Szűcs Gábor).
>
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> >      joining column's datatypes do not match
>
> it looks very important, but I cannot understand it. Sound as a small
> and easy mistake that can make things go sour...
>
> Can someone explain it please?

Note that this is mostly fixed in V 8.0

What it means is that if you have a table with a field of type numeric,
and you join another table against it with a field of type integer, the
query planner won't know it can use the indexes on those two fields
(assuming you DO have indexes on them) when joining and use a sequential
scan all the time.

Casting one field to the other's type, or changing the type of one to
the other's type will allow the planner to use the index.


pgsql-sql by date:

Previous
From: Alain
Date:
Subject: Tip ?
Next
From: lucas@presserv.org
Date:
Subject: Duplicated records