X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3345252834 for ; Tue, 24 May 2005 15:34:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89293-09 for ; Tue, 24 May 2005 18:34:07 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id 3D9DA52830 for ; Tue, 24 May 2005 15:34:06 -0300 (ADT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 24 May 2005 13:34:07 -0500 Subject: Re: Tip ? From: Scott Marlowe To: Alain Cc: Sql-Postgre In-Reply-To: <429371EA.30502@pobox.com> References: <05d801c41bd8$daf4f8f0$0403a8c0@fejleszt4> <42930447.2030801@gmail.com> <429371EA.30502@pobox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <1116959646.31821.278.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 24 May 2005 13:34:07 -0500 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/208 X-Sequence-Number: 21521 On Tue, 2005-05-24 at 13:26, Alain wrote: > This tip was at the end of a message (from Sz=C5=B1cs G=C3=A1bor). >=20 > > TIP 9: the planner will ignore your desire to choose an index scan if y= our > > joining column's datatypes do not match >=20 > it looks very important, but I cannot understand it. Sound as a small=20 > and easy mistake that can make things go sour... >=20 > 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.