Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BCDD41337B83 for ; Tue, 8 Feb 2011 01:21:14 -0400 (AST) 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 90350-05 for ; Tue, 8 Feb 2011 05:21:07 +0000 (UTC) X-Greylist: delayed 00:05:38.326212 by SQLgrey-1.7.6 Received: from shrek.krogh.cc (2605ds1-ynoe.0.fullrate.dk [90.184.12.24]) by mail.postgresql.org (Postfix) with ESMTP id 6AEBE1337B34 for ; Tue, 8 Feb 2011 01:21:07 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id 90E481595A5 for ; Tue, 8 Feb 2011 06:15:26 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc Received: from shrek.krogh.cc ([127.0.0.1]) by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bXldUZhaTxbn for ; Tue, 8 Feb 2011 06:15:23 +0100 (CET) Received: from [90.184.13.151] (2605ds1-ynoe.2.fullrate.dk [90.184.13.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jesper@krogh.cc) by shrek.krogh.cc (Postfix) with ESMTPSA id 67E131DAE5E for ; Tue, 8 Feb 2011 06:15:23 +0100 (CET) Message-ID: <4D50D16A.1060802@krogh.cc> Date: Tue, 08 Feb 2011 06:15:22 +0100 From: Jesper Krogh User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Indexes with condition using immutable functions applied to column not used References: <1297124098.2549.65.camel@kheops> In-Reply-To: <1297124098.2549.65.camel@kheops> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201102/298 X-Sequence-Number: 42436 On 2011-02-08 01:14, Sylvain Rabot wrote: > CREATE INDEX directory_id_user_mod_cons_hash_0_btree_idx ON mike.directory USING btree (id_user) WHERE __mod_cons_hash(id_user, 4) = 0; > CREATE INDEX directory_id_user_mod_cons_hash_1_btree_idx ON mike.directory USING btree (id_user) WHERE __mod_cons_hash(id_user, 4) = 1; > CREATE INDEX directory_id_user_mod_cons_hash_2_btree_idx ON mike.directory USING btree (id_user) WHERE __mod_cons_hash(id_user, 4) = 2; > CREATE INDEX directory_id_user_mod_cons_hash_3_btree_idx ON mike.directory USING btree (id_user) WHERE __mod_cons_hash(id_user, 4) = 3; > > mike=# EXPLAIN ANALYZE SELECT * FROM directory WHERE id_user = 4; Should be written as: select * from directory where __mod_cons_hash(id_user,4) = 4%4; Then it should just work. -- Jesper