From: | 安西 直也 <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp> |
---|---|
To: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org, 岩浅 晃郎 <iwaasa(at)mxs(dot)nes(dot)nec(dot)co(dot)jp> |
Subject: | Re: BUG #6283: About the behavior of indexscan in case there are some NULL values. |
Date: | 2011-11-02 09:39:48 |
Message-ID: | 11CC99435D0E8Canzai-naoya@mxu.nes.nec.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)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 Scan using 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 Scan Backward 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
---
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-11-02 16:38:03 | Re: BUG #6283: About the behavior of indexscan in case there are some NULL values. |
Previous Message | Craig Ringer | 2011-11-02 09:38:53 | Re: BUG #6281: need to remove |