Hello,
It appears that predicate indexes won't uses indexes on int8 columns
unless they are casted:
test=# select count(*) from test_key ;count
--------120617
(1 row)
test=# alter table test_key ALTER column id set statistics 25;
ALTER TABLE
test=# analyze test_key ;
test=# create index foo on test_key (id) where id >= 50000;
CREATE INDEX
test=# analyze;
ANALYZE
test=# explain analyze select * from test_key where id > 50000; QUERY
PLAN
-----------------------------------------------------------------------------------------------------------------Seq
Scanon test_key (cost=0.00..2276.71 rows=69768 width=16) (actual
time=23.186..289.406 rows=70617 loops=1) Filter: (id > 50000)Total runtime: 516.917 ms
(3 rows)
test=# create index foo on test_key (id) where id >= 50000::bigint;
CREATE INDEX
test=# analyze;
ANALYZE
test=# explain analyze select * from test_key where id > 50000::bigint;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------Index
Scanusing foo on test_key (cost=0.00..1602.88 rows=70806
width=16) (actual time=0.080..264.001 rows=70617 loops=1) Index Cond: (id > 50000::bigint)Total runtime: 496.160 ms
(3 rows)
test=# explain analyze select * from test_key where id > 50000;
QUERYPLAN
----------------------------------------------------------------------------------------------------------------------------Index
Scanusing foo on test_key (cost=0.00..1602.88 rows=70806
width=16) (actual time=0.116..262.952 rows=70617 loops=1) Index Cond: (id > 50000)Total runtime: 488.943 ms
(3 rows)