Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9676

Andrew Dunstan: LATERAL subqueries - coming to a PostgreSQL release near you ...

$
0
0
Tom Lane has just posted a message that begins thus to the hackers list:
I've been idly amusing myself by trying to hack up support for
SQL-standard LATERAL subqueries. I've got something that turns over,
more or less:
regression=# select * from int4_tbl a, lateral (select unique1,unique2 from tenk1 b where a.f1 = unique1) x;
 f1 | unique1 | unique2 
----+---------+---------
  0 |       0 |    9998
(1 row)

regression=# explain select * from int4_tbl a, lateral (select unique1,unique2 from tenk1 b where a.f1 = unique1) x;
                                    QUERY PLAN                                     
-----------------------------------------------------------------------------------
 Nested Loop  (cost=0.00..42.55 rows=5 width=12)
   ->  Seq Scan on int4_tbl a  (cost=0.00..1.05 rows=5 width=4)
   ->  Index Scan using tenk1_unique1 on tenk1 b  (cost=0.00..8.28 rows=1 width=8)
         Index Cond: (a.f1 = unique1)
(4 rows)


This is just fantastic. I have lost count of the number of times I have wanted this feature. PostgreSQL just keeps getting better.

Viewing all articles
Browse latest Browse all 9676

Trending Articles