-> Index Only Scan Backward using tenk1_unique2 on tenk1
Index Cond: (unique2 IS NOT NULL)
-> Result
-(7 rows)
+(9 rows)
select distinct max(unique2) from tenk1;
max
insert into minmaxtest3 values(17), (18);
explain (costs off, nodes off)
select min(f1), max(f1) from minmaxtest;
- QUERY PLAN
-----------------------------------------------------------------------------------------------
- Result
- InitPlan 1 (returns $0)
- -> Limit
- -> Merge Append
- Sort Key: minmaxtest.f1
- -> Index Only Scan using minmaxtesti on minmaxtest
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest1i on minmaxtest1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest2i on minmaxtest2
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest3i on minmaxtest3
- Index Cond: (f1 IS NOT NULL)
- InitPlan 2 (returns $1)
- -> Limit
- -> Merge Append
- Sort Key: minmaxtest_1.f1 DESC
- -> Index Only Scan Backward using minmaxtesti on minmaxtest minmaxtest_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest1_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest2_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest3_1
- Index Cond: (f1 IS NOT NULL)
-(25 rows)
+ QUERY PLAN
+-------------------------------------------
+ Aggregate
+ -> Append
+ -> Remote Subquery Scan on all
+ -> Seq Scan on minmaxtest
+ -> Remote Subquery Scan on all
+ -> Seq Scan on minmaxtest1
+ -> Remote Subquery Scan on all
+ -> Seq Scan on minmaxtest2
+ -> Remote Subquery Scan on all
+ -> Seq Scan on minmaxtest3
+(10 rows)
select min(f1), max(f1) from minmaxtest;
min | max
-- DISTINCT doesn't do anything useful here, but it shouldn't fail
explain (costs off)
select distinct min(f1), max(f1) from minmaxtest;
- QUERY PLAN
-----------------------------------------------------------------------------------------------
+ QUERY PLAN
+-----------------------------------------------------------------------
HashAggregate
- Group Key: $0, $1
- InitPlan 1 (returns $0)
- -> Limit
- -> Merge Append
- Sort Key: minmaxtest.f1
- -> Index Only Scan using minmaxtesti on minmaxtest
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest1i on minmaxtest1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest2i on minmaxtest2
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest3i on minmaxtest3
- Index Cond: (f1 IS NOT NULL)
- InitPlan 2 (returns $1)
- -> Limit
- -> Merge Append
- Sort Key: minmaxtest_1.f1 DESC
- -> Index Only Scan Backward using minmaxtesti on minmaxtest minmaxtest_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest1_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest2_1
- Index Cond: (f1 IS NOT NULL)
- -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest3_1
- Index Cond: (f1 IS NOT NULL)
- -> Result
-(27 rows)
+ Group Key: min(minmaxtest.f1), max(minmaxtest.f1)
+ -> Aggregate
+ -> Append
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on minmaxtest
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on minmaxtest1
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on minmaxtest2
+ -> Remote Subquery Scan on all (datanode_1,datanode_2)
+ -> Seq Scan on minmaxtest3
+(12 rows)
select distinct min(f1), max(f1) from minmaxtest;
min | max