Re: Partial index and query plan

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Aleksandr Vinokurov" <aleksandr(dot)vin(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Partial index and query plan
Date: 2007-08-22 14:43:00
Message-ID: dcc563d10708220743h37f85ae5scb183bb9e6e85073@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 8/22/07, Aleksandr Vinokurov <aleksandr(dot)vin(at)gmail(dot)com> wrote:
>
> create table user_history (
> rec_id SERIAL not null,
> date TIMESTAMP not null,
> action INT2 not null,
> uid INT4 not null,
> name CHAR(10) null default NULL,
> constraint PK_USER_HISTORY primary key (rec_id),
> constraint AK_DATE_USER_HIS unique (date)
> );
>
> create unique index indx_date_action12_uid_user_his
> on user_history (date, uid)
> where action <> 0;
>
> and this query:
>
> select date
> from "user_history"
> where date > '2007-08-18 14:33'
> and date <= '2007-08-18 16:30'
> and uid = 1388
> and action <> 0
> limit 1;
>
>
> The question is why "explain analyze" shows a 'Filter: ("action" <> 0)' in plan:
>
> Limit (cost=0.00..3.05 rows=1 width=8) (actual time=4.798..4.798
> rows=0 loops=1)
> -> Index Scan using indx_date_action12_uid_user_his on
> user_history (cost=0.00..6.10 rows=2 width=8) (actual
> time=4.791..4.791 rows=0 loops=1)
> Index Cond: ((date > '2007-08-18 14:33:40.60664'::timestamp
> without time zone) AND (date <= '2007-08-18 16:30:00'::timestamp
> without time zone) AND (uid = 138658))
> Filter: ("action" <> 0)

I don't see the issue here. The index being used is the same partial
index you created. Maybe it's just a question of semantics?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Aleksandr Vinokurov 2007-08-22 15:02:03 Re: Partial index and query plan
Previous Message Aleksandr Vinokurov 2007-08-22 14:32:03 Re: Partial index and query plan