not null partial index? - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject not null partial index?
Date
Msg-id 20041031.125237.15272438.t-ishii@sra.co.jp
Whole thread Raw
Responses Re: not null partial index?
List pgsql-hackers
It seems partial indexes with not null condition do not work:
I did some testings with pgbench database and I observe:

1) statistics information is slghtly incorrect

2) partial index is not used

Am I missing something?
--
Tatsuo Ishii

$ psql test
Welcome to psql 7.4.6, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms      \h for help with SQL commands      \? for help on internal slash commands
    \g or terminate with semicolon to execute query      \q to quit
 

Pager usage is off.
test=# \d accounts      Table "public.accounts" Column  |     Type      | Modifiers 
----------+---------------+-----------aid      | integer       | not nullbid      | integer       | abalance | integer
    | filler   | character(84) | 
 
Indexes:   "accounts_pkey" primary key, btree (aid)

test=# update accounts set bid = NULL;
UPDATE 100000
test=# update accounts set bid = 1 where aid = 1;
UPDATE 1
test=# create index nonnullindex on accounts((bid is not null));
CREATE INDEX
test=# vacuum analyze accounts;
VACUUM
test=# explain select * from accounts where bid is not null;                           QUERY PLAN
    
 
------------------------------------------------------------------Seq Scan on accounts  (cost=0.00..4227.00 rows=100000
width=100) Filter: (bid IS NOT NULL)
 
(2 rows)

test=# vacuum full accounts;
VACUUM
test=# explain select * from accounts where bid is not null;                           QUERY PLAN
    
 
------------------------------------------------------------------Seq Scan on accounts  (cost=0.00..2588.00 rows=100000
width=100) Filter: (bid IS NOT NULL)
 
(2 rows)

test=# select count(*) from accounts where bid is not null;count 
-------    1
(1 row)


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Charset/collate support and function parameters
Next
From: Dennis Bjorklund
Date:
Subject: Re: Charset/collate support and function parameters