Re: BUG #6283: About the behavior of indexscan in case there are some NULL values.

Поиск
Список
Период
Сортировка
От 安西 直也
Тема Re: BUG #6283: About the behavior of indexscan in case there are some NULL values.
Дата
Msg-id 11CC99435D0E8Canzai-naoya@mxu.nes.nec.co.jp
обсуждение исходный текст
Ответ на BUG #6283: About the behavior of indexscan in case there are some NULL values.  ("Naoya Anzai" <anzai-naoya@mxu.nes.nec.co.jp>)
Ответы Re: BUG #6283: About the behavior of indexscan in case there are some NULL values.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
>>
>> Hello,
>>
>> In the newest PostgreSQL(9.1.1) or lower, Index-Scan's actual time may
>> increase unexpectedly.
>>
>> I think that this is for scanning All NULL VALUES when performing an
>> indexscan
>> even if they does not need to be scanned.
>
>I think this was just fixed. Please check latest source code.

I have checked latest source code.
But, backward scan doesn't work correctly...

==========================================
[naoya@nesitcspg03 ~]$ psql
psql (9.2devel)
Type "help" for help.

naoya=# create table hoge(id integer,id2 integer);
CREATE TABLE
naoya=# insert into hoge select generate_series(1,10);
INSERT 0 10
naoya=# update hoge set id2=1 where id=5;
UPDATE 1
naoya=# update hoge set id2=10 where id=7;
UPDATE 1
naoya=# create index hoge_idx on hoge(id2);
CREATE INDEX
naoya=# analyze hoge;
ANALYZE
naoya=# set enable_bitmapscan to off;
SET
naoya=# set enable_seqscan to off;
SET
naoya=# select * from hoge;id | id2
----+----- 1 | 2 | 3 | 4 | 6 | 8 | 9 |10 | 5 |   1 7 |  10
(10 rows)

naoya=# explain analyze select * from hoge where id2>0;                                                 QUERY PLAN

---------------------------------------------------------------------------------------------------------------Index
Scanusing hoge_idx on hoge  (cost=0.00..8.29 rows=2 width=8) (actual time=0.010..0.012 rows=2 loops=1)  Index Cond:
(id2> 0)Total runtime: 0.065 ms 
(3 rows)

naoya=# explain analyze select * from hoge where id2>0 order by id2 desc;
      QUERY PLAN 


------------------------------------------------------------------------------------------------------------------------Index
ScanBackward using hoge_idx on hoge  (cost=0.00..8.29 rows=2 width=8) (actual time=0.005..0.005 rows=0 loops=1)  Index
Cond:(id2 > 0)Total runtime: 0.035 ms 
(3 rows)

naoya=# select * from hoge where id2>0;id | id2
----+----- 5 |   1 7 |  10
(2 rows)

naoya=# select * from hoge where id2>0 order by id2 desc;id | id2
----+-----
(0 rows)

==========================================

Regards.

---
Naoya Anzai
---


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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: BUG #6281: need to remove
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #6283: About the behavior of indexscan in case there are some NULL values.