> The optimizer does not think that "pbx_date = CURRENT_DATE" satisfies the
> partial index's WHERE condition. I don't see any really good way around
> this; to improve matters there'd need to be some concept of a plan that
> is only good for a limited time.
It's the same as the slight issue I had:
CREATE INDEX users_users_referrer_idx ON users_users(referrer) WHERE
(referrer IS NOT NULL);
usa=# explain analyze select * from users_users where referrer=1; QUERY
PLAN
----------------------------------------------------------------------------
---------------------------Seq Scan on users_users (cost=0.00..3.89 rows=8 width=235) (actual
time=10.51..13.47 rows=8 loops=1) Filter: (referrer = 1)
usa=# explain analyze select * from users_users where referrer=1 and
referrer is not null; QUERY PLAN
----------------------------------------------------------------------------
------------------------------------------------------------Index Scan using users_users_referrer_idx on users_users
(cost=0.00..3.01
rows=1 width=235) (actual time=17.12..17.36 rows=8 loops=1)
Obviously to you and I, referrer=1 implies that referrer is not null, but
the planner doesn't know that. You often have to add a redundant clause to
the query to ensure that the partial index is used.
Chris