index scan is performed when index-only scan is possible (partial index)

Поиск
Список
Период
Сортировка
От Alexey Bashtanov
Тема index scan is performed when index-only scan is possible (partial index)
Дата
Msg-id 52F8C727.3020409@imap.cc
обсуждение исходный текст
Ответы Re: index scan is performed when index-only scan is possible (partial index)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Hello!

It seems to me there is a situation where index-only scan is possible
but not performed.

-----
[ACTIONS]
 > create table t as select a, a % 2 b, a % 2 c from generate_series(1,
1000000) a order by random();
SELECT 1000000
 > create index t_i1 on t (a, c) where b = 1;
CREATE INDEX
 > analyze t;
ANALYZE
 > EXPLAIN select a from t where a < 10000 and b = 1 order by a;
                              QUERY PLAN
---------------------------------------------------------------------
  Index Scan using t_i1 on t  (cost=0.42..14013.07 rows=5094 width=4)
    Index Cond: (a < 10000)
(2 rows)

 > create index t_i2 on t (a, b) where b = 1;
CREATE INDEX
 > EXPLAIN select a from t where a < 10000 and b = 1 order by a;
                                 QUERY PLAN
--------------------------------------------------------------------------
  Index Only Scan using t_i2 on t  (cost=0.42..14009.07 rows=5094 width=4)
    Index Cond: ((a < 10000) AND (b = 1))
(2 rows)

[EXPECTED]
in both cases index-only scan is performed

[RECEIVED]
in the first case index scan is performed, though index-only scan is
possible, as no conditions rechecking is required
-----

adding (b=1) expression to index as a column does not help

Regards, Alexey

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #9169: Replica (v 9.3.2) crashed with "PANIC: WAL contains references to invalid pages"
Следующее
От: ste013@hotmail.fr
Дата:
Сообщение: BUG #9164: impossible to install