1[
2    {
3        "testcase": "Combination of USE INDEX and USE HASH hints, Hash Join build outer. Explain",
4        "ignore": "index_id",
5        "explain": {
6            "disabled": false,
7            "results": [
8                {
9                    "present": true
10                }
11            ],
12            "statement": "SELECT true AS present FROM $explan AS p WHERE ANY v WITHIN p.plan.`~children` SATISFIES v.`#operator` = 'HashJoin' END"
13        },
14        "statements":"SELECT c.firstName, c.lastName, c.customerId, p.purchaseId FROM customer c USE INDEX (cust_lastName_firstName_customerId) JOIN purchase p USE INDEX (purch_customerId_purchaseId) HASH(probe) ON c.customerId = p.customerId WHERE c.lastName = \"Champlin\" ORDER BY p.purchaseId LIMIT 10",
15        "ordered": true,
16        "results": [
17        {
18            "customerId": "customer60",
19            "firstName": "Bryon",
20            "lastName": "Champlin",
21            "purchaseId": "purchase104"
22        },
23        {
24            "customerId": "customer33",
25            "firstName": "Charles",
26            "lastName": "Champlin",
27            "purchaseId": "purchase1582"
28        },
29        {
30            "customerId": "customer33",
31            "firstName": "Charles",
32            "lastName": "Champlin",
33            "purchaseId": "purchase1704"
34        },
35        {
36            "customerId": "customer60",
37            "firstName": "Bryon",
38            "lastName": "Champlin",
39            "purchaseId": "purchase1747"
40        },
41        {
42            "customerId": "customer631",
43            "firstName": "Gladyce",
44            "lastName": "Champlin",
45            "purchaseId": "purchase2838"
46        },
47        {
48            "customerId": "customer631",
49            "firstName": "Gladyce",
50            "lastName": "Champlin",
51            "purchaseId": "purchase2872"
52        },
53        {
54            "customerId": "customer60",
55            "firstName": "Bryon",
56            "lastName": "Champlin",
57            "purchaseId": "purchase3344"
58        },
59        {
60            "customerId": "customer60",
61            "firstName": "Bryon",
62            "lastName": "Champlin",
63            "purchaseId": "purchase3698"
64        },
65        {
66            "customerId": "customer60",
67            "firstName": "Bryon",
68            "lastName": "Champlin",
69            "purchaseId": "purchase4142"
70        },
71        {
72            "customerId": "customer60",
73            "firstName": "Bryon",
74            "lastName": "Champlin",
75            "purchaseId": "purchase4315"
76        }
77    ]
78    },
79    {
80        "testcase": "USE HASH hints on first keyspace, error",
81        "statements":"SELECT c.firstName, c.lastName, c.customerId, p.purchaseId FROM customer c USE HASH(build) JOIN purchase p USE INDEX (purch_customerId_purchaseId, purch_purchaseId) ON c.customerId = p.customerId WHERE c.lastName = \"Champlin\" AND c.type = \"customer\" ORDER BY p.purchaseId LIMIT 10",
82        "error": "Join hint (USE HASH or USE NL) cannot be specified on the first keyspace c - at JOIN"
83    },
84    {
85        "testcase": "Combination of USE INDEX and USE HASH hints, ON-clause has OR clause, USE HASH hint igored. Explain",
86        "ignore": "index_id",
87        "explain": {
88            "disabled": false,
89            "results": [
90                {
91                    "present": true
92                }
93            ],
94            "statement": "SELECT true AS present FROM $explan AS p WHERE ANY v WITHIN p.plan.`~children` SATISFIES v.`#operator` = 'NestedLoopJoin' END"
95        },
96        "statements":"SELECT c.firstName, c.lastName, c.customerId, p.purchaseId FROM customer c JOIN purchase p USE HASH(probe) INDEX (purch_customerId_purchaseId, purch_purchaseId) ON p.customerId = c.customerId OR p.purchaseId = \"purchase8992\" WHERE c.lastName = \"Champlin\" ORDER BY p.purchaseId LIMIT 10 OFFSET 10",
97        "ordered": true,
98        "results": [
99        {
100            "customerId": "customer60",
101            "firstName": "Bryon",
102            "lastName": "Champlin",
103            "purchaseId": "purchase436"
104        },
105        {
106            "customerId": "customer33",
107            "firstName": "Charles",
108            "lastName": "Champlin",
109            "purchaseId": "purchase4534"
110        },
111        {
112            "customerId": "customer631",
113            "firstName": "Gladyce",
114            "lastName": "Champlin",
115            "purchaseId": "purchase4627"
116        },
117        {
118            "customerId": "customer60",
119            "firstName": "Bryon",
120            "lastName": "Champlin",
121            "purchaseId": "purchase5193"
122        },
123        {
124            "customerId": "customer631",
125            "firstName": "Gladyce",
126            "lastName": "Champlin",
127            "purchaseId": "purchase5610"
128        },
129        {
130            "customerId": "customer60",
131            "firstName": "Bryon",
132            "lastName": "Champlin",
133            "purchaseId": "purchase5889"
134        },
135        {
136            "customerId": "customer33",
137            "firstName": "Charles",
138            "lastName": "Champlin",
139            "purchaseId": "purchase5988"
140        },
141        {
142            "customerId": "customer60",
143            "firstName": "Bryon",
144            "lastName": "Champlin",
145            "purchaseId": "purchase6084"
146        },
147        {
148            "customerId": "customer631",
149            "firstName": "Gladyce",
150            "lastName": "Champlin",
151            "purchaseId": "purchase6530"
152        },
153        {
154            "customerId": "customer33",
155            "firstName": "Charles",
156            "lastName": "Champlin",
157            "purchaseId": "purchase6985"
158        }
159    ]
160    },
161    {
162        "testcase": "Combination of USE KEYS and USE HASH hints, Hash Join not used due to subquery in USE KEYS. Explain",
163        "ignore": "index_id",
164        "explain": {
165            "disabled": false,
166            "results": [
167                {
168                    "present": true
169                }
170            ],
171            "statement": "SELECT true AS present FROM $explan AS p WHERE ANY v WITHIN p.plan.`~children` SATISFIES v.`#operator` = 'NestedLoopJoin' END"
172        },
173        "statements":"SELECT c.firstName, c.lastName, c.customerId, p.purchaseId FROM customer c USE INDEX (cust_lastName_firstName_customerId) JOIN purchase p USE HASH(probe) KEYS (select raw meta().id from purchase where customerId in [\"customer33\", \"customer60\", \"customer631\"]) ON c.customerId = p.customerId WHERE c.lastName = \"Champlin\" ORDER BY p.purchaseId LIMIT 10",
174        "ordered": true,
175        "results": [
176        {
177            "customerId": "customer60",
178            "firstName": "Bryon",
179            "lastName": "Champlin",
180            "purchaseId": "purchase104"
181        },
182        {
183            "customerId": "customer33",
184            "firstName": "Charles",
185            "lastName": "Champlin",
186            "purchaseId": "purchase1582"
187        },
188        {
189            "customerId": "customer33",
190            "firstName": "Charles",
191            "lastName": "Champlin",
192            "purchaseId": "purchase1704"
193        },
194        {
195            "customerId": "customer60",
196            "firstName": "Bryon",
197            "lastName": "Champlin",
198            "purchaseId": "purchase1747"
199        },
200        {
201            "customerId": "customer631",
202            "firstName": "Gladyce",
203            "lastName": "Champlin",
204            "purchaseId": "purchase2838"
205        },
206        {
207            "customerId": "customer631",
208            "firstName": "Gladyce",
209            "lastName": "Champlin",
210            "purchaseId": "purchase2872"
211        },
212        {
213            "customerId": "customer60",
214            "firstName": "Bryon",
215            "lastName": "Champlin",
216            "purchaseId": "purchase3344"
217        },
218        {
219            "customerId": "customer60",
220            "firstName": "Bryon",
221            "lastName": "Champlin",
222            "purchaseId": "purchase3698"
223        },
224        {
225            "customerId": "customer60",
226            "firstName": "Bryon",
227            "lastName": "Champlin",
228            "purchaseId": "purchase4142"
229        },
230        {
231            "customerId": "customer60",
232            "firstName": "Bryon",
233            "lastName": "Champlin",
234            "purchaseId": "purchase4315"
235        }
236    ]
237    },
238    {
239        "testcase": "Combination of USE KEYS and USE HASH hints, Hash Join build inner. Explain",
240        "ignore": "index_id",
241        "explain": {
242            "disabled": false,
243            "results": [
244                {
245                    "present": true
246                }
247            ],
248            "statement": "SELECT true AS present FROM $explan AS p WHERE ANY v WITHIN p.plan.`~children` SATISFIES v.`#operator` = 'HashJoin' END"
249        },
250        "statements":"SELECT c.firstName, c.lastName, c.customerId, p.purchaseId FROM customer c JOIN purchase p USE KEYS [\"purchase1582_hashjoin\", \"purchase1704_hashjoin\", \"purchase4534_hashjoin\", \"purchase5988_hashjoin\", \"purchase6985_hashjoin\", \"purchase7352_hashjoin\", \"purchase8538_hashjoin\", \"purchase8992_hashjoin\", \"purchase9287_hashjoin\", \"purchase104_hashjoin\", \"purchase1747_hashjoin\", \"purchase3344_hashjoin\", \"purchase3698_hashjoin\", \"purchase4142_hashjoin\", \"purchase4315_hashjoin\", \"purchase436_hashjoin\", \"purchase5193_hashjoin\", \"purchase5889_hashjoin\", \"purchase6084_hashjoin\", \"purchase8349_hashjoin\", \"purchase9300_hashjoin\", \"purchase2838_hashjoin\", \"purchase2872_hashjoin\", \"purchase4627_hashjoin\", \"purchase5610_hashjoin\", \"purchase6530_hashjoin\", \"purchase993_hashjoin\"] HASH(build) ON c.customerId = p.customerId WHERE c.lastName = \"Champlin\" ORDER BY p.purchaseId LIMIT 10",
251        "ordered": true,
252        "results": [
253        {
254            "customerId": "customer60",
255            "firstName": "Bryon",
256            "lastName": "Champlin",
257            "purchaseId": "purchase104"
258        },
259        {
260            "customerId": "customer33",
261            "firstName": "Charles",
262            "lastName": "Champlin",
263            "purchaseId": "purchase1582"
264        },
265        {
266            "customerId": "customer33",
267            "firstName": "Charles",
268            "lastName": "Champlin",
269            "purchaseId": "purchase1704"
270        },
271        {
272            "customerId": "customer60",
273            "firstName": "Bryon",
274            "lastName": "Champlin",
275            "purchaseId": "purchase1747"
276        },
277        {
278            "customerId": "customer631",
279            "firstName": "Gladyce",
280            "lastName": "Champlin",
281            "purchaseId": "purchase2838"
282        },
283        {
284            "customerId": "customer631",
285            "firstName": "Gladyce",
286            "lastName": "Champlin",
287            "purchaseId": "purchase2872"
288        },
289        {
290            "customerId": "customer60",
291            "firstName": "Bryon",
292            "lastName": "Champlin",
293            "purchaseId": "purchase3344"
294        },
295        {
296            "customerId": "customer60",
297            "firstName": "Bryon",
298            "lastName": "Champlin",
299            "purchaseId": "purchase3698"
300        },
301        {
302            "customerId": "customer60",
303            "firstName": "Bryon",
304            "lastName": "Champlin",
305            "purchaseId": "purchase4142"
306        },
307        {
308            "customerId": "customer60",
309            "firstName": "Bryon",
310            "lastName": "Champlin",
311            "purchaseId": "purchase4315"
312        }
313    ]
314    }
315]
316
317