Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id CE8AFB5DBCB for ; Wed, 14 Sep 2011 09:50:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 28948-10 for ; Wed, 14 Sep 2011 12:50:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id E8129B5D91F for ; Wed, 14 Sep 2011 09:50:07 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1R3oul-00053M-6s for pgsql-performance@postgresql.org; Wed, 14 Sep 2011 05:50:07 -0700 Date: Wed, 14 Sep 2011 05:50:07 -0700 (PDT) From: MirrorX To: pgsql-performance@postgresql.org Message-ID: <1316004607207-4802634.post@n5.nabble.com> Subject: cannot use multicolumn index MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.767 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201109/255 X-Sequence-Number: 45031 dear all, i have a table with (approx) 500.000.000 rows. it has several indexes, one of which is a multicolumn index for a column that has an id (integer) and a column that has a timestamp. i have read in the manual that the multicolumn index can be used only if the clauses of the query are in the same order as the columns of the index. so i am trying the following simple query -> server=# explain select count(*) from temp_by_hour where xid > 100 and xdate > now() - interval '1 week'; * QUERY PLAN ------------------------------------------------------------------------------------------------ Aggregate (cost=29356607.86..29356607.87 rows=1 width=0) -> Seq Scan on temp_by_hour i (cost=0.00..29342531.72 rows=5630456 width=0) Filter: ((xid > 100) AND (xdate > (now() - '7 days'::interval)))* and the index is this -> *"temp_by_hour_idx" btree (xid, xdate)* the size of the index is this -> * public | temp_by_hour_idx | index | mydb| temp_by_hour | 35 GB * and the size of the table is this -> * public |temp_by_hour | table | mydb| 115 GB * any ideas on how i should write to query to use this index? thx in advance -- View this message in context: http://postgresql.1045698.n5.nabble.com/cannot-use-multicolumn-index-tp4802634p4802634.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com.