Explain reports unexpected results with inheritance - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Explain reports unexpected results with inheritance
Date
Msg-id 200102141821.f1EIL2w67836@hub.org
Whole thread Raw
Responses Re: Explain reports unexpected results with inheritance  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
David Lynn (davidl@ayamba.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Explain reports unexpected results with inheritance

Long Description
When tab2 inherits tab1, explain in psql will always report a "Seq Scan" on tab2 even if there are appropriate indexes.
Through additional testing, it appears that the index is actually being used based on relative cost numbers, but that
explainis just not reporting as such. 

Using 7.0.2.

Sample Code
DEV:menu# create table tab1 (col1 int4);
CREATE
DEV:menu# create table tab2 (col2 int4) inherits (tab1);
CREATE
DEV:menu# insert into tab2 (col1, col2) values (1,1);
INSERT 28995 1
DEV:menu# insert into tab2 (col1, col2) values (2,2);
INSERT 28996 1
DEV:menu# create index idx1 on tab2 (col2);
CREATE
DEV:menu# select * from tab2 where col2 = 2;
 col1 | col2
------+------
    2 |    2
(1 row)

DEV:menu# explain select * from tab2 where col2 = 2;
NOTICE:  QUERY PLAN:

Seq Scan on tab2  (cost=0.00..1.02 rows=1 width=8)

EXPLAIN


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Sequence increased before constraint check
Next
From: Peter Eisentraut
Date:
Subject: Re: Sequence increased before constraint check