X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 34E4CD1B4A2 for ; Mon, 5 Jan 2004 12:05:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56464-08 for ; Mon, 5 Jan 2004 08:05:05 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id F1093D1B48E for ; Mon, 5 Jan 2004 08:05:01 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1AdTTm-0006Zi-9I; Mon, 05 Jan 2004 13:05:06 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1AdTTl-0006ZT-M4; Mon, 05 Jan 2004 13:05:05 +0100 In-Reply-To: <200401051705.55120.shridhar_daithankar@myrealbox.com> References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> <200401051705.55120.shridhar_daithankar@myrealbox.com> Mime-Version: 1.0 (Apple Message framework v609) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: David Teran Subject: Re: optimizing Postgres queries Date: Mon, 5 Jan 2004 13:05:03 +0100 To: Shridhar Daithankar X-Mailer: Apple Mail (2.609) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/28 X-Sequence-Number: 5203 Hi Shridhar, > Are you sure you are using correct data types on indexes? > Did not know about this... > e.g. if field1 is an int2 field, then following query would not use an > index. > our fk have the type bigint, when i try one simple select like this: explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE t0.ID_FOREIGN_TABLE = 21110; i see that no index is being used whereas when i use explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE t0.ID_FOREIGN_TABLE = 21110::bigint; an index is used. Very fine, the performance is about 10 to 100 times faster for the single select. I am using WebObjects with JDBC. I will now create a DB with integer instead of bigint and see how this performs. regards David