[HACKERS] null values / partial indices

2002-11-13 Thread Mario Weilguni
I noticed that the planner is unable to select an index scan when a partial index is available, the partial index is based on a NOT NULL condition. Example: start with no index: mydb=# EXPLAIN ANALYZE select id from str where url='foobar'; NOTICE: QUERY PLAN: Seq Scan on str (cost=0.00..88.91

Re: [HACKERS] null values / partial indices

2002-11-13 Thread Zeugswetter Andreas SB SD
mydb=# create index str_idx_url on str(url) where url is not null; CREATE mydb=# analyze str; ANALYZE mydb=# EXPLAIN ANALYZE select id from str where url='foobar'; NOTICE: QUERY PLAN: Seq Scan on str (cost=0.00..91.05 rows=3 width=4) (actual You can try an index like: create index

Re: [HACKERS] null values / partial indices

2002-11-13 Thread Mario Weilguni
You can try an index like: create index str_idx_url on str(url) where url = ''; I think that should be identical. ('' is the smallest string, no ?) Thanks alot, it works now. But I still think the NOT NULL case would be useful. Best regards, Mario Weilguni

Re: [HACKERS] null values / partial indices

2002-11-13 Thread Tom Lane
Mario Weilguni [EMAIL PROTECTED] writes: I noticed that the planner is unable to select an index scan when a partial index is available, the partial index is based on a NOT NULL condition. It wants you to do this: select id from str where url='foobar' and url is not null; I know and you know