Re: Indexes with condition using immutable functions applied to column not used

From: Jesper Krogh <jesper(at)krogh(dot)cc>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Indexes with condition using immutable functions applied to column not used
Date: 2011-02-08 05:15:22
Message-ID: 4D50D16A.1060802@krogh.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jakub Ouhrabka 2011-02-08 08:41:12 Re: Write-heavy pg_stats_collector on mostly idle server
Previous Message Scott Marlowe 2011-02-08 04:25:45 Re: Really really slow select count(*)