@@ -1210,24 +1210,22 @@ select * from matest0 order by 1-id;
12101210reset enable_indexscan;
12111211set enable_seqscan = off; -- plan with fewest seqscans should be merge
12121212explain (verbose, costs off) select * from matest0 order by 1-id;
1213- QUERY PLAN
1214- ------------------------------------------------------------------------
1215- Result
1216- Output: matest0.id, matest0.name, ((1 - matest0.id))
1217- -> Merge Append
1218- Sort Key: ((1 - matest0.id))
1219- -> Index Scan using matest0i on public.matest0
1220- Output: matest0.id, matest0.name, (1 - matest0.id)
1221- -> Index Scan using matest1i on public.matest1
1222- Output: matest1.id, matest1.name, (1 - matest1.id)
1223- -> Sort
1224- Output: matest2.id, matest2.name, ((1 - matest2.id))
1225- Sort Key: ((1 - matest2.id))
1226- -> Seq Scan on public.matest2
1227- Output: matest2.id, matest2.name, (1 - matest2.id)
1228- -> Index Scan using matest3i on public.matest3
1229- Output: matest3.id, matest3.name, (1 - matest3.id)
1230- (15 rows)
1213+ QUERY PLAN
1214+ ------------------------------------------------------------------
1215+ Merge Append
1216+ Sort Key: ((1 - matest0.id))
1217+ -> Index Scan using matest0i on public.matest0
1218+ Output: matest0.id, matest0.name, (1 - matest0.id)
1219+ -> Index Scan using matest1i on public.matest1
1220+ Output: matest1.id, matest1.name, (1 - matest1.id)
1221+ -> Sort
1222+ Output: matest2.id, matest2.name, ((1 - matest2.id))
1223+ Sort Key: ((1 - matest2.id))
1224+ -> Seq Scan on public.matest2
1225+ Output: matest2.id, matest2.name, (1 - matest2.id)
1226+ -> Index Scan using matest3i on public.matest3
1227+ Output: matest3.id, matest3.name, (1 - matest3.id)
1228+ (13 rows)
12311229
12321230select * from matest0 order by 1-id;
12331231 id | name
@@ -1258,48 +1256,45 @@ SELECT thousand, tenthous FROM tenk1
12581256UNION ALL
12591257SELECT thousand, thousand FROM tenk1
12601258ORDER BY thousand, tenthous;
1261- QUERY PLAN
1262- -------------------------------------------------------------------------------
1263- Result
1264- -> Merge Append
1265- Sort Key: tenk1.thousand, tenk1.tenthous
1266- -> Index Only Scan using tenk1_thous_tenthous on tenk1
1267- -> Sort
1268- Sort Key: tenk1_1.thousand, tenk1_1.thousand
1269- -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1
1270- (7 rows)
1259+ QUERY PLAN
1260+ -------------------------------------------------------------------------
1261+ Merge Append
1262+ Sort Key: tenk1.thousand, tenk1.tenthous
1263+ -> Index Only Scan using tenk1_thous_tenthous on tenk1
1264+ -> Sort
1265+ Sort Key: tenk1_1.thousand, tenk1_1.thousand
1266+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1
1267+ (6 rows)
12711268
12721269explain (costs off)
12731270SELECT thousand, tenthous, thousand+tenthous AS x FROM tenk1
12741271UNION ALL
12751272SELECT 42, 42, hundred FROM tenk1
12761273ORDER BY thousand, tenthous;
1277- QUERY PLAN
1278- ------------------------------------------------------------------------
1279- Result
1280- -> Merge Append
1281- Sort Key: tenk1.thousand, tenk1.tenthous
1282- -> Index Only Scan using tenk1_thous_tenthous on tenk1
1283- -> Sort
1284- Sort Key: (42), (42)
1285- -> Index Only Scan using tenk1_hundred on tenk1 tenk1_1
1286- (7 rows)
1274+ QUERY PLAN
1275+ ------------------------------------------------------------------
1276+ Merge Append
1277+ Sort Key: tenk1.thousand, tenk1.tenthous
1278+ -> Index Only Scan using tenk1_thous_tenthous on tenk1
1279+ -> Sort
1280+ Sort Key: (42), (42)
1281+ -> Index Only Scan using tenk1_hundred on tenk1 tenk1_1
1282+ (6 rows)
12871283
12881284explain (costs off)
12891285SELECT thousand, tenthous FROM tenk1
12901286UNION ALL
12911287SELECT thousand, random()::integer FROM tenk1
12921288ORDER BY thousand, tenthous;
1293- QUERY PLAN
1294- -------------------------------------------------------------------------------
1295- Result
1296- -> Merge Append
1297- Sort Key: tenk1.thousand, tenk1.tenthous
1298- -> Index Only Scan using tenk1_thous_tenthous on tenk1
1299- -> Sort
1300- Sort Key: tenk1_1.thousand, ((random())::integer)
1301- -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1
1302- (7 rows)
1289+ QUERY PLAN
1290+ -------------------------------------------------------------------------
1291+ Merge Append
1292+ Sort Key: tenk1.thousand, tenk1.tenthous
1293+ -> Index Only Scan using tenk1_thous_tenthous on tenk1
1294+ -> Sort
1295+ Sort Key: tenk1_1.thousand, ((random())::integer)
1296+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1
1297+ (6 rows)
13031298
13041299-- Check min/max aggregate optimization
13051300explain (costs off)
@@ -1345,16 +1340,15 @@ SELECT x, y FROM
13451340 UNION ALL
13461341 SELECT unique2 AS x, unique2 AS y FROM tenk1 b) s
13471342ORDER BY x, y;
1348- QUERY PLAN
1349- -------------------------------------------------------------------
1350- Result
1351- -> Merge Append
1352- Sort Key: a.thousand, a.tenthous
1353- -> Index Only Scan using tenk1_thous_tenthous on tenk1 a
1354- -> Sort
1355- Sort Key: b.unique2, b.unique2
1356- -> Index Only Scan using tenk1_unique2 on tenk1 b
1357- (7 rows)
1343+ QUERY PLAN
1344+ -------------------------------------------------------------
1345+ Merge Append
1346+ Sort Key: a.thousand, a.tenthous
1347+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 a
1348+ -> Sort
1349+ Sort Key: b.unique2, b.unique2
1350+ -> Index Only Scan using tenk1_unique2 on tenk1 b
1351+ (6 rows)
13581352
13591353reset enable_seqscan;
13601354reset enable_indexscan;
0 commit comments