@@ -110,15 +110,15 @@ SELECT str FROM expln('
110
110
JOINS: 0
111
111
(6 rows)
112
112
113
- -- TODO: Should learn on postgres_fdw nodes
113
+ -- Should learn on postgres_fdw nodes
114
114
SELECT str FROM expln('
115
115
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)
116
116
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
117
117
') AS str WHERE str NOT LIKE '%Query Identifier%';
118
118
str
119
119
--------------------------------------------------------------------------------------------------------
120
120
Foreign Scan (actual rows=1 loops=1)
121
- AQO not used
121
+ AQO: rows=1, error=0%
122
122
Output: a.x, b.x
123
123
Relations: (public.frgn a) INNER JOIN (public.frgn b)
124
124
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x = r2.x))))
@@ -127,6 +127,39 @@ SELECT str FROM expln('
127
127
JOINS: 0
128
128
(8 rows)
129
129
130
+ CREATE TABLE local_a(aid int primary key, aval text);
131
+ CREATE TABLE local_b(bid int primary key, aid int references local_a(aid), bval text);
132
+ INSERT INTO local_a SELECT i, 'val_' || i FROM generate_series(1,100) i;
133
+ INSERT INTO local_b SELECT i, mod((i+random()*10)::numeric, 10) + 1, 'val_' || i FROM generate_series(1,1000) i;
134
+ ANALYZE local_a, local_b;
135
+ CREATE FOREIGN TABLE frgn_a(aid int, aval text) SERVER loopback OPTIONS (table_name 'local_a');
136
+ CREATE FOREIGN TABLE frgn_b(bid int, aid int, bval text) SERVER loopback OPTIONS (table_name 'local_b');
137
+ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
138
+ SELECT * from frgn_a AS a, frgn_b AS b
139
+ WHERE a.aid = b.aid AND b.bval like 'val%';
140
+ QUERY PLAN
141
+ -----------------------------------------------
142
+ Foreign Scan (actual rows=1000 loops=1)
143
+ AQO not used
144
+ Relations: (frgn_a a) INNER JOIN (frgn_b b)
145
+ Using aqo: true
146
+ AQO mode: LEARN
147
+ JOINS: 0
148
+ (6 rows)
149
+
150
+ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
151
+ SELECT * from frgn_a AS a, frgn_b AS b
152
+ WHERE a.aid = b.aid AND b.bval like 'val%';
153
+ QUERY PLAN
154
+ -----------------------------------------------
155
+ Foreign Scan (actual rows=1000 loops=1)
156
+ AQO: rows=1000, error=0%
157
+ Relations: (frgn_a a) INNER JOIN (frgn_b b)
158
+ Using aqo: true
159
+ AQO mode: LEARN
160
+ JOINS: 0
161
+ (6 rows)
162
+
130
163
-- TODO: Non-mergejoinable join condition.
131
164
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
132
165
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
@@ -147,7 +180,7 @@ SELECT str FROM expln('
147
180
str
148
181
--------------------------------------------------------------------------------------------------------
149
182
Foreign Scan (actual rows=0 loops=1)
150
- AQO not used
183
+ AQO: rows=1, error=100%
151
184
Output: a.x, b.x
152
185
Relations: (public.frgn a) INNER JOIN (public.frgn b)
153
186
Remote SQL: SELECT r1.x, r2.x FROM (public.local r1 INNER JOIN public.local r2 ON (((r1.x < r2.x))))
@@ -158,8 +191,12 @@ SELECT str FROM expln('
158
191
159
192
DROP EXTENSION aqo CASCADE;
160
193
DROP EXTENSION postgres_fdw CASCADE;
161
- NOTICE: drop cascades to 3 other objects
194
+ NOTICE: drop cascades to 5 other objects
162
195
DETAIL: drop cascades to server loopback
163
196
drop cascades to user mapping for public on server loopback
164
197
drop cascades to foreign table frgn
198
+ drop cascades to foreign table frgn_a
199
+ drop cascades to foreign table frgn_b
165
200
DROP TABLE local;
201
+ DROP TABLE local_b;
202
+ DROP TABLE local_a;
0 commit comments