SQL:
CREATE TABLE test (id BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT);
INSERT INTO test SELECT i, i, i, i FROM generate_series(0, 9) i;
EXPLAIN ANALYZE SELECT ((SELECT tmp::test FROM (SELECT * FROM test
LIMIT 1) tmp)::test).*;
WILL:
QUERY PLAN
Result (cost=0.11..0.12 rows=1 width=0) (actual time=0.076..0.078
rows=1 loops=1)
InitPlan
-> Subquery Scan tmp (cost=0.00..0.03 rows=1 width=32) (actual
time=0.014..0.019 rows=1 loops=1)
-> Limit (cost=0.00..0.02 rows=1 width=32) (actual
time=0.008..0.009 rows=1 loops=1)
-> Seq Scan on test (cost=0.00..23.10 rows=1310
width=32) (actual time=0.005..0.005 rows=1 loops=1)
-> Subquery Scan tmp (cost=0.00..0.03 rows=1 width=32) (actual
time=0.008..0.013 rows=1 loops=1)
-> Limit (cost=0.00..0.02 rows=1 width=32) (actual
time=0.005..0.006 rows=1 loops=1)
-> Seq Scan on test (cost=0.00..23.10 rows=1310
width=32) (actual time=0.002..0.002 rows=1 loops=1)
-> Subquery Scan tmp (cost=0.00..0.03 rows=1 width=32) (actual
time=0.008..0.012 rows=1 loops=1)
-> Limit (cost=0.00..0.02 rows=1 width=32) (actual
time=0.005..0.006 rows=1 loops=1)
-> Seq Scan on test (cost=0.00..23.10 rows=1310
width=32) (actual time=0.003..0.003 rows=1 loops=1)
-> Subquery Scan tmp (cost=0.00..0.03 rows=1 width=32) (actual
time=0.009..0.013 rows=1 loops=1)
-> Limit (cost=0.00..0.02 rows=1 width=32) (actual
time=0.005..0.006 rows=1 loops=1)
-> Seq Scan on test (cost=0.00..23.10 rows=1310
width=32) (actual time=0.002..0.002 rows=1 loops=1)
Total runtime: 0.138 ms
One subquery for each column. wtf?