Re: Crazy query plan. - Mailing list pgsql-bugs

From Craig Ringer
Subject Re: Crazy query plan.
Date
Msg-id 4AFE3533.3030403@postnewspapers.com.au
Whole thread Raw
In response to Re: Crazy query plan.  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Crazy query plan.
List pgsql-bugs
> This may be simplified to the comparison between these two queries:

... or even further into:

CREATE TYPE test AS ( a integer, b integer, c integer, d integer );
EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test);
EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test).*;


craig=# EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test);
                    QUERY PLAN
--------------------------------------------------
 Result  (cost=0.01..0.02 rows=1 width=0)
   InitPlan
     ->  Result  (cost=0.00..0.01 rows=1 width=0)
(3 rows)

craig=# EXPLAIN SELECT ((SELECT ROW(1,1,1,1)::test)::test).*;
                    QUERY PLAN
--------------------------------------------------
 Result  (cost=0.04..0.05 rows=1 width=0)
   InitPlan
     ->  Result  (cost=0.00..0.01 rows=1 width=0)
     ->  Result  (cost=0.00..0.01 rows=1 width=0)
     ->  Result  (cost=0.00..0.01 rows=1 width=0)
     ->  Result  (cost=0.00..0.01 rows=1 width=0)
(6 rows)





Something odd I stumbled upon while testing for this:

craig=# SELECT tmp FROM (SELECT ((SELECT ROW(1,1,1,1)::test)::test)) AS tmp;
      tmp
---------------
 ("(1,1,1,1)")
(1 row)

... is fine,

craig=# SELECT tmp.* FROM (SELECT ((SELECT ROW(1,1,1,1)::test)::test))
AS tmp;
   test
-----------
 (1,1,1,1)
(1 row)

... is fine,

craig=# SELECT (tmp.*).* FROM (SELECT ((SELECT
ROW(1,1,1,1)::test)::test)) AS tmp;
   test
-----------
 (1,1,1,1)
(1 row)

... is ... WTF? How is "(tmp.*).*" the same as "tmp.*" ?


--
Craig Ringer

pgsql-bugs by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Crazy query plan.
Next
From: Craig Ringer
Date:
Subject: Re: Crazy query plan.