X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 10706D1E2A0 for ; Thu, 29 Apr 2004 20:45:24 -0300 (ADT) 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 33783-10 for ; Thu, 29 Apr 2004 20:45:05 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id D449BD1E31C for ; Thu, 29 Apr 2004 20:45:02 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i3TNj2Sx097842 for ; Thu, 29 Apr 2004 23:45:02 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i3TNJ7rt054355 for pgsql-performance@postgresql.org; Thu, 29 Apr 2004 23:19:07 GMT From: Joseph Shraibman X-Newsgroups: comp.databases.postgresql.performance Subject: why can't 2 indexes be used at once? Date: Thu, 29 Apr 2004 19:19:09 -0400 Organization: Hub.Org Networking Services Lines: 12 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/515 X-Sequence-Number: 6815 Lets say I have two columns, A and B. They are each indexed seperately. If I do a query like: SELECT * FROM table WHERE A = 1 AND B = 2; postgres can only use one index. I assume that postgres uses the index data to narrow down pages in the table to visit when doing its search. Then it goes through and filters on the second condition. My question: why can't it go through the first index, get a list of pages in the table, then go through the second index, union the result with the results from first index, and then go into the table?