Re: Reference to parent query from ANY sublink - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Reference to parent query from ANY sublink
Date
Msg-id 16862.1386805758@sss.pgh.pa.us
Whole thread Raw
In response to Re: Reference to parent query from ANY sublink  (Antonin Houska <antonin.houska@gmail.com>)
Responses Re: Reference to parent query from ANY sublink
List pgsql-hackers
Antonin Houska <antonin.houska@gmail.com> writes:
> debug_print_plan output contains
> :grpColIdx 2
> in the AGG node.

Hm, that means there's only one grouping column (and it's the second
tlist entry of the child plan node).  So that seems conclusive that
the unique-ification is being done wrong.  It's not very clear why
though.  It doesn't seem like your patch is doing anything that
would directly affect that.

For comparison purposes, using the patch I just posted, I get
this description of a correct plan:

regression=# explain verbose SELECT * FROM SUBSELECT_TBL upper WHERE (f1, f2::float) IN   (SELECT f2, f3 FROM
SUBSELECT_TBL);                                           QUERY PLAN                                             
 
----------------------------------------------------------------------------------------------------Hash Join
(cost=41.55..84.83rows=442 width=16)  Output: upper.f1, upper.f2, upper.f3  Hash Cond: ((upper.f1 = subselect_tbl.f2)
AND((upper.f2)::double precision = subselect_tbl.f3))  ->  Seq Scan on public.subselect_tbl upper  (cost=0.00..27.70
rows=1770width=16)        Output: upper.f1, upper.f2, upper.f3  ->  Hash  (cost=38.55..38.55 rows=200 width=12)
Output:subselect_tbl.f2, subselect_tbl.f3        ->  HashAggregate  (cost=36.55..38.55 rows=200 width=12)
Output:subselect_tbl.f2, subselect_tbl.f3              Group Key: subselect_tbl.f2, subselect_tbl.f3              ->
SeqScan on public.subselect_tbl  (cost=0.00..27.70 rows=1770 width=12)                    Output: subselect_tbl.f1,
subselect_tbl.f2,subselect_tbl.f3
 
(12 rows)

so it's unique-ifying on both f2 and f3, which is clearly necessary
for executing the IN with a plain join.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: Reference to parent query from ANY sublink
Next
From: desmodemone
Date:
Subject: Re: In-Memory Columnar Store