@@ -35,6 +35,109 @@ SELECT count(*) FROM tmp1;
35
35
(1 row)
36
36
37
37
DROP TABLE tmp1;
38
+ EXPLAIN SELECT * FROM aqo_test0
39
+ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
40
+ QUERY PLAN
41
+ ----------------------------------------------------------------------------------
42
+ Index Scan using aqo_test0_idx_a on aqo_test0 (cost=0.28..8.35 rows=1 width=16)
43
+ Index Cond: (a < 3)
44
+ Filter: ((b < 3) AND (c < 3) AND (d < 3))
45
+ (3 rows)
46
+
47
+ EXPLAIN SELECT t1.a, t2.b, t3.c
48
+ FROM aqo_test1 AS t1, aqo_test0 AS t2, aqo_test0 AS t3
49
+ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b = t3.b;
50
+ QUERY PLAN
51
+ ------------------------------------------------------------------------------------------------
52
+ Nested Loop (cost=0.28..50.59 rows=1 width=12)
53
+ Join Filter: (t1.b = t3.b)
54
+ -> Nested Loop (cost=0.28..9.56 rows=1 width=12)
55
+ -> Seq Scan on aqo_test1 t1 (cost=0.00..1.25 rows=1 width=8)
56
+ Filter: (a < 1)
57
+ -> Index Scan using aqo_test0_idx_a on aqo_test0 t2 (cost=0.28..8.30 rows=1 width=8)
58
+ Index Cond: (a = t1.a)
59
+ Filter: (c < 1)
60
+ -> Seq Scan on aqo_test0 t3 (cost=0.00..41.02 rows=1 width=8)
61
+ Filter: ((b < 1) AND (d < 0))
62
+ (10 rows)
63
+
64
+ CREATE EXTENSION aqo;
65
+ SET aqo.mode = 'intelligent';
66
+ CREATE TABLE tmp1 AS SELECT * FROM aqo_test0
67
+ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
68
+ SELECT count(*) FROM tmp1;
69
+ count
70
+ -------
71
+ 3
72
+ (1 row)
73
+
74
+ DROP TABLE tmp1;
75
+ CREATE TABLE tmp1 AS SELECT t1.a, t2.b, t3.c
76
+ FROM aqo_test1 AS t1, aqo_test0 AS t2, aqo_test0 AS t3
77
+ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b = t3.b;
78
+ SELECT count(*) FROM tmp1;
79
+ count
80
+ -------
81
+ 0
82
+ (1 row)
83
+
84
+ DROP TABLE tmp1;
85
+ SET aqo.mode = 'manual';
86
+ UPDATE aqo_queries SET learn_aqo = true, use_aqo = true, auto_tuning = false;
87
+ EXPLAIN SELECT * FROM aqo_test0
88
+ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
89
+ QUERY PLAN
90
+ ----------------------------------------------------------------------------------
91
+ Index Scan using aqo_test0_idx_a on aqo_test0 (cost=0.28..8.35 rows=3 width=16)
92
+ Index Cond: (a < 3)
93
+ Filter: ((b < 3) AND (c < 3) AND (d < 3))
94
+ (3 rows)
95
+
96
+ EXPLAIN SELECT t1.a, t2.b, t3.c
97
+ FROM aqo_test1 AS t1, aqo_test0 AS t2, aqo_test0 AS t3
98
+ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b = t3.b;
99
+ QUERY PLAN
100
+ ------------------------------------------------------------------------------------------------
101
+ Nested Loop (cost=0.28..50.59 rows=1 width=12)
102
+ Join Filter: (t1.b = t3.b)
103
+ -> Nested Loop (cost=0.28..9.56 rows=1 width=12)
104
+ -> Seq Scan on aqo_test1 t1 (cost=0.00..1.25 rows=1 width=8)
105
+ Filter: (a < 1)
106
+ -> Index Scan using aqo_test0_idx_a on aqo_test0 t2 (cost=0.28..8.30 rows=1 width=8)
107
+ Index Cond: (a = t1.a)
108
+ Filter: (c < 1)
109
+ -> Seq Scan on aqo_test0 t3 (cost=0.00..41.02 rows=1 width=8)
110
+ Filter: ((b < 1) AND (d < 0))
111
+ (10 rows)
112
+
113
+ SET aqo.mode = 'disabled';
114
+ EXPLAIN SELECT * FROM aqo_test0
115
+ WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
116
+ QUERY PLAN
117
+ ----------------------------------------------------------------------------------
118
+ Index Scan using aqo_test0_idx_a on aqo_test0 (cost=0.28..8.35 rows=1 width=16)
119
+ Index Cond: (a < 3)
120
+ Filter: ((b < 3) AND (c < 3) AND (d < 3))
121
+ (3 rows)
122
+
123
+ EXPLAIN SELECT t1.a, t2.b, t3.c
124
+ FROM aqo_test1 AS t1, aqo_test0 AS t2, aqo_test0 AS t3
125
+ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b = t3.b;
126
+ QUERY PLAN
127
+ ------------------------------------------------------------------------------------------------
128
+ Nested Loop (cost=0.28..50.59 rows=1 width=12)
129
+ Join Filter: (t1.b = t3.b)
130
+ -> Nested Loop (cost=0.28..9.56 rows=1 width=12)
131
+ -> Seq Scan on aqo_test1 t1 (cost=0.00..1.25 rows=1 width=8)
132
+ Filter: (a < 1)
133
+ -> Index Scan using aqo_test0_idx_a on aqo_test0 t2 (cost=0.28..8.30 rows=1 width=8)
134
+ Index Cond: (a = t1.a)
135
+ Filter: (c < 1)
136
+ -> Seq Scan on aqo_test0 t3 (cost=0.00..41.02 rows=1 width=8)
137
+ Filter: ((b < 1) AND (d < 0))
138
+ (10 rows)
139
+
140
+ DROP EXTENSION aqo;
38
141
DROP INDEX aqo_test0_idx_a;
39
142
DROP TABLE aqo_test0;
40
143
DROP INDEX aqo_test1_idx_a;
0 commit comments