Partial Indexes condtions

Поиск
Список
Период
Сортировка
От Donald Fraser
Тема Partial Indexes condtions
Дата
Msg-id 001401c36187$47380a00$1664a8c0@DEMOLITION
обсуждение исходный текст
Ответы Re: Partial Indexes condtions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
PostgreSQL 7.3.3, GCC 2.96 on Redhat 7.2

Not sure whether you classify this as a bug or not?
Anyway here goes:

I have a partial index such as:
CREATE UNIQUE INDEX tbl_test_key
  ON tbl_test
  USING btree
  (s_mnem)
  WHERE ((n_status & (~9)) <> 0);

I have a select statement such as:
SELECT s_mnem FROM tbl_test WHERE (n_status & (~9) <> 0);

It doesn't matter what I do (including SET enable_seqscan TO OFF)
Explain shows that the planner always chooses a sequential scan.

Now if I change the partial index to the following:
CREATE UNIQUE INDEX tbl_test_key
  ON tbl_test
  USING btree
  (s_mnem)
  WHERE ((n_status & -10) <> 0);

Note: the binary inverse of 9 is -10.

Explain shows that the planner now chooses to use the partial index?

Regards
Donald Fraser.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "systems"
Дата:
Сообщение: Slow Query
Следующее
От: Christopher Marshall
Дата:
Сообщение: JDBC Metadata bug