@@ -104,7 +104,7 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
104
104
QUERY PLAN
105
105
--------------------------------------------------------------------------------------------------------
106
106
Foreign Scan (actual rows=1 loops=1)
107
- AQO not used
107
+ AQO: rows=1, error=0%
108
108
Output: a.x, b.x
109
109
Relations: (public.frgn a) INNER JOIN (public.frgn b)
110
110
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x = r2.x))))
@@ -113,6 +113,39 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
113
113
JOINS: 0
114
114
(8 rows)
115
115
116
+ CREATE TABLE local_a(aid int primary key, aval text);
117
+ CREATE TABLE local_b(bid int primary key, aid int references local_a(aid), bval text);
118
+ INSERT INTO local_a SELECT i, 'val_' || i FROM generate_series(1,100) i;
119
+ INSERT INTO local_b SELECT i, mod((i+random()*10)::numeric, 10) + 1, 'val_' || i FROM generate_series(1,1000) i;
120
+ ANALYZE local_a, local_b;
121
+ CREATE FOREIGN TABLE frgn_a(aid int, aval text) SERVER loopback OPTIONS (table_name 'local_a');
122
+ CREATE FOREIGN TABLE frgn_b(bid int, aid int, bval text) SERVER loopback OPTIONS (table_name 'local_b');
123
+ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
124
+ SELECT * from frgn_a AS a, frgn_b AS b
125
+ WHERE a.aid = b.aid AND b.bval like 'val%';
126
+ QUERY PLAN
127
+ -----------------------------------------------
128
+ Foreign Scan (actual rows=1000 loops=1)
129
+ AQO not used
130
+ Relations: (frgn_a a) INNER JOIN (frgn_b b)
131
+ Using aqo: true
132
+ AQO mode: LEARN
133
+ JOINS: 0
134
+ (6 rows)
135
+
136
+ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
137
+ SELECT * from frgn_a AS a, frgn_b AS b
138
+ WHERE a.aid = b.aid AND b.bval like 'val%';
139
+ QUERY PLAN
140
+ -----------------------------------------------
141
+ Foreign Scan (actual rows=1000 loops=1)
142
+ AQO: rows=1000, error=0%
143
+ Relations: (frgn_a a) INNER JOIN (frgn_b b)
144
+ Using aqo: true
145
+ AQO mode: LEARN
146
+ JOINS: 0
147
+ (6 rows)
148
+
116
149
-- TODO: Non-mergejoinable join condition.
117
150
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
118
151
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
@@ -131,7 +164,7 @@ SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
131
164
QUERY PLAN
132
165
--------------------------------------------------------------------------------------------------------
133
166
Foreign Scan (actual rows=0 loops=1)
134
- AQO not used
167
+ AQO: rows=1, error=100%
135
168
Output: a.x, b.x
136
169
Relations: (public.frgn a) INNER JOIN (public.frgn b)
137
170
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x < r2.x))))
@@ -142,8 +175,12 @@ SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
142
175
143
176
DROP EXTENSION aqo CASCADE;
144
177
DROP EXTENSION postgres_fdw CASCADE;
145
- NOTICE: drop cascades to 3 other objects
178
+ NOTICE: drop cascades to 5 other objects
146
179
DETAIL: drop cascades to server loopback
147
180
drop cascades to user mapping for public on server loopback
148
181
drop cascades to foreign table frgn
182
+ drop cascades to foreign table frgn_a
183
+ drop cascades to foreign table frgn_b
149
184
DROP TABLE local;
185
+ DROP TABLE local_b;
186
+ DROP TABLE local_a;
0 commit comments