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 718D1D1B4CC for ; Mon, 5 Jan 2004 18:54:39 +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 41752-02 for ; Mon, 5 Jan 2004 14:53:49 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id A8791D1B433 for ; Mon, 5 Jan 2004 14:53:03 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05Iqf19016231; Mon, 5 Jan 2004 13:52:41 -0500 (EST) To: David Teran Cc: Shridhar Daithankar , pgsql-performance@postgresql.org Subject: Re: optimizing Postgres queries In-reply-to: <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> <200401051705.55120.shridhar_daithankar@myrealbox.com> <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> <200401051740.05006.shridhar_daithankar@myrealbox.com> <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> <9966.1073316152@sss.pgh.pa.us> <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> Comments: In-reply-to David Teran message dated "Mon, 05 Jan 2004 19:47:28 +0100" Date: Mon, 05 Jan 2004 13:52:40 -0500 Message-ID: <16230.1073328760@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/41 X-Sequence-Number: 5216 David Teran writes: > What we found out now is that a query with a single 'where' works fine, > the query planer uses the index but when we have 'two' where clauses it > does not use the index anymore: > EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE > (t0."ID_VALUE" = 14542); performs fine, less than one millisecond. > EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE > (t0."ID_VALUE" = 14542 OR t0."ID_VALUE" = 14550); performs bad: about > 235 milliseconds. Please, when you ask this sort of question, show the EXPLAIN ANALYZE output. It is not a virtue to provide minimal information and see if anyone can guess what's happening. regards, tom lane