Re: [HACKERS] Quals not pushed down into lateral - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [HACKERS] Quals not pushed down into lateral
Date
Msg-id CA+TgmoZk=ubtVi9Ym6i6AOYyLObiM2NvvpKjtFG_WA+g=2H9=g@mail.gmail.com
Whole thread Raw
In response to [HACKERS] Quals not pushed down into lateral  (Andres Freund <andres@anarazel.de>)
Responses Re: [HACKERS] Quals not pushed down into lateral  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Thu, Mar 16, 2017 at 4:45 AM, Andres Freund <andres@anarazel.de> wrote:
> During citus development we noticed that restrictions aren't pushed down
> into lateral subqueries, even if they semantically could.  For example,
> in this dumbed down example:
>
> postgres[31776][1]=# CREATE TABLE t_2(id serial primary key);
> postgres[31776][1]=# CREATE TABLE t_1(id serial primary key);
>
> Comparing:
>
> postgres[31776][1]=# EXPLAIN SELECT * FROM t_1 JOIN (SELECT * FROM t_2 GROUP BY id) s ON (t_1.id = s.id) WHERE t_1.id
=3;
 
> postgres[31776][1]=# EXPLAIN SELECT * FROM t_1, LATERAL (SELECT * FROM t_2 WHERE t_1.id = t_2.id GROUP BY id) s WHERE
t_1.id= 3;
 

Interesting.  That does seem like we are missing a trick.

Not exactly related, but I think we need to improve optimization
around CTEs, too.  AFAICT, what we've got right now, almost everybody
hates.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: [HACKERS] Row Level Security UPDATE Confusion
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] Quals not pushed down into lateral