Query time 0.01125
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "400.41"
},
"grouping_operation": {
"using_filesort": false,
"nested_loop": [
{
"table": {
"table_name": "jmj_discussion",
"access_type": "range",
"possible_keys": [
"object_id"
],
"key": "object_id",
"used_key_parts": [
"object_id",
"object_type"
],
"key_length": "6",
"rows_examined_per_scan": 44,
"rows_produced_per_join": 44,
"filtered": "100.00",
"index_condition": "((`jmj_test`.`jmj_discussion`.`object_id` in (1676,811,812,891,892,893,929,930,982,950,955,957,959,961,964,966,834,835,836,837,838,839,840,841,842,843,845,846,847,849,850,851,852,853,854,855,859,860,861,910,916,1531,1534,1439)) and (`jmj_test`.`jmj_discussion`.`object_type` = 'P'))",
"cost_info": {
"read_cost": "96.81",
"eval_cost": "8.80",
"prefix_cost": "105.61",
"data_read_per_join": "1K"
},
"used_columns": [
"thread_id",
"object_id",
"object_type",
"type"
]
}
},
{
"table": {
"table_name": "jmj_discussion_posts",
"access_type": "ref",
"possible_keys": [
"thread_id",
"thread_id_2"
],
"key": "thread_id",
"used_key_parts": [
"thread_id"
],
"key_length": "3",
"ref": [
"jmj_test.jmj_discussion.thread_id"
],
"rows_examined_per_scan": 3,
"rows_produced_per_join": 132,
"filtered": "100.00",
"cost_info": {
"read_cost": "110.00",
"eval_cost": "26.40",
"prefix_cost": "242.01",
"data_read_per_join": "57K"
},
"used_columns": [
"post_id",
"thread_id",
"status"
],
"attached_condition": "<if>(is_not_null_compl(jmj_discussion_posts), (`jmj_test`.`jmj_discussion_posts`.`status` = 'A'), true)"
}
},
{
"table": {
"table_name": "jmj_discussion_rating",
"access_type": "eq_ref",
"possible_keys": [
"PRIMARY",
"thread_id"
],
"key": "PRIMARY",
"used_key_parts": [
"post_id"
],
"key_length": "3",
"ref": [
"jmj_test.jmj_discussion_posts.post_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 132,
"filtered": "100.00",
"cost_info": {
"read_cost": "132.00",
"eval_cost": "26.40",
"prefix_cost": "400.41",
"data_read_per_join": "2K"
},
"used_columns": [
"rating_value",
"post_id",
"thread_id"
],
"attached_condition": "<if>(is_not_null_compl(jmj_discussion_rating), ((`jmj_test`.`jmj_discussion_rating`.`thread_id` = `jmj_test`.`jmj_discussion`.`thread_id`) and (`jmj_test`.`jmj_discussion_rating`.`rating_value` <> 0)), true)"
}
}
]
}
}
}
Result
| product_id |
average_rating |
discussion_type |
discussion_thread_id |
| 811 |
|
B |
277 |
| 812 |
|
B |
278 |
| 834 |
|
B |
329 |
| 835 |
|
B |
330 |
| 836 |
|
B |
331 |
| 837 |
|
B |
332 |
| 838 |
|
B |
333 |
| 839 |
|
B |
334 |
| 840 |
|
B |
335 |
| 841 |
|
B |
336 |
| 842 |
|
B |
337 |
| 843 |
|
B |
338 |
| 845 |
|
B |
340 |
| 846 |
|
B |
341 |
| 847 |
|
B |
342 |
| 849 |
|
B |
344 |
| 850 |
|
B |
345 |
| 851 |
|
B |
346 |
| 852 |
|
B |
347 |
| 853 |
|
B |
348 |
| 854 |
|
B |
349 |
| 855 |
|
B |
350 |
| 859 |
|
B |
354 |
| 860 |
|
B |
355 |
| 861 |
|
B |
356 |
| 891 |
|
B |
386 |
| 892 |
|
B |
387 |
| 893 |
|
B |
388 |
| 910 |
|
B |
417 |
| 916 |
|
B |
423 |
| 929 |
|
B |
437 |
| 930 |
|
B |
438 |
| 950 |
|
B |
460 |
| 955 |
|
B |
465 |
| 957 |
|
B |
467 |
| 959 |
|
B |
469 |
| 961 |
|
B |
471 |
| 964 |
|
B |
474 |
| 966 |
|
B |
476 |
| 982 |
|
B |
492 |
| 1439 |
|
B |
964 |
| 1531 |
|
B |
1056 |
| 1534 |
|
B |
1059 |
| 1676 |
|
B |
1235 |