Re: Reference to parent query from ANY sublink

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Antonin Houska <antonin(dot)houska(at)gmail(dot)com>
Cc: Kevin Grittner <kgrittn(at)ymail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reference to parent query from ANY sublink
Date: 2013-12-11 23:49:18
Message-ID: 16862.1386805758@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Antonin Houska <antonin(dot)houska(at)gmail(dot)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.83 rows=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=1770 width=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
-> Seq Scan 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message desmodemone 2013-12-12 00:06:44 Re: In-Memory Columnar Store
Previous Message Antonin Houska 2013-12-11 23:31:37 Re: Reference to parent query from ANY sublink