Query time 0.00102
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "55.46"
},
"grouping_operation": {
"using_temporary_table": true,
"using_filesort": false,
"nested_loop": [
{
"table": {
"table_name": "cscart_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": 48,
"rows_produced_per_join": 48,
"filtered": "100.00",
"index_condition": "((`nuie_scalesta_net`.`cscart_discussion`.`object_id` in (94930,94931,94932,94933,94934,94935,94936,94937,94938,94939,94940,94941,94942,94943,94944,94945,94946,94947,94948,94949,95100,95558,95559,95560,95638,95640,95645,95646,95653,95790,95932,95933,95936,95940,96245,96246,96247,96248,96249,96250,96251,96252,96253,96254,96255,96256,96257,96258)) and (`nuie_scalesta_net`.`cscart_discussion`.`object_type` = 'P'))",
"cost_info": {
"read_cost": "28.81",
"eval_cost": "4.80",
"prefix_cost": "33.61",
"data_read_per_join": "1K"
},
"used_columns": [
"thread_id",
"object_id",
"object_type",
"type"
]
}
},
{
"table": {
"table_name": "cscart_discussion_posts",
"access_type": "ref",
"possible_keys": [
"thread_id",
"thread_id_2"
],
"key": "thread_id",
"used_key_parts": [
"thread_id"
],
"key_length": "3",
"ref": [
"nuie_scalesta_net.cscart_discussion.thread_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 48,
"filtered": "100.00",
"cost_info": {
"read_cost": "12.00",
"eval_cost": "4.80",
"prefix_cost": "50.41",
"data_read_per_join": "21K"
},
"used_columns": [
"post_id",
"thread_id",
"status"
],
"attached_condition": "<if>(is_not_null_compl(cscart_discussion_posts), (`nuie_scalesta_net`.`cscart_discussion_posts`.`status` = 'A'), true)"
}
},
{
"table": {
"table_name": "cscart_discussion_rating",
"access_type": "ALL",
"possible_keys": [
"PRIMARY",
"thread_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 48,
"filtered": "100.00",
"using_join_buffer": "hash join",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "4.80",
"prefix_cost": "55.46",
"data_read_per_join": "768"
},
"used_columns": [
"rating_value",
"post_id",
"thread_id"
],
"attached_condition": "<if>(is_not_null_compl(cscart_discussion_rating), ((`nuie_scalesta_net`.`cscart_discussion_rating`.`post_id` = `nuie_scalesta_net`.`cscart_discussion_posts`.`post_id`) and (`nuie_scalesta_net`.`cscart_discussion_rating`.`thread_id` = `nuie_scalesta_net`.`cscart_discussion`.`thread_id`) and (`nuie_scalesta_net`.`cscart_discussion_rating`.`rating_value` <> 0)), true)"
}
}
]
}
}
}
Result
| product_id |
average_rating |
discussion_type |
discussion_thread_id |
| 94930 |
|
B |
103102 |
| 94931 |
|
B |
103103 |
| 94932 |
|
B |
103104 |
| 94933 |
|
B |
103105 |
| 94934 |
|
B |
103106 |
| 94935 |
|
B |
103107 |
| 94936 |
|
B |
103108 |
| 94937 |
|
B |
103109 |
| 94938 |
|
B |
103110 |
| 94939 |
|
B |
103111 |
| 94940 |
|
B |
103112 |
| 94941 |
|
B |
103113 |
| 94942 |
|
B |
103114 |
| 94943 |
|
B |
103115 |
| 94944 |
|
B |
103116 |
| 94945 |
|
B |
103117 |
| 94946 |
|
B |
103118 |
| 94947 |
|
B |
103119 |
| 94948 |
|
B |
103120 |
| 94949 |
|
B |
103121 |
| 95100 |
|
B |
103272 |
| 95558 |
|
B |
103730 |
| 95559 |
|
B |
103731 |
| 95560 |
|
B |
103732 |
| 95638 |
|
B |
103810 |
| 95640 |
|
B |
103812 |
| 95645 |
|
B |
103817 |
| 95646 |
|
B |
103818 |
| 95653 |
|
B |
103825 |
| 95790 |
|
B |
103962 |
| 95932 |
|
B |
104104 |
| 95933 |
|
B |
104105 |
| 95936 |
|
B |
104108 |
| 95940 |
|
B |
104112 |
| 96245 |
|
B |
104417 |
| 96246 |
|
B |
104418 |
| 96247 |
|
B |
104419 |
| 96248 |
|
B |
104420 |
| 96249 |
|
B |
104421 |
| 96250 |
|
B |
104422 |
| 96251 |
|
B |
104423 |
| 96252 |
|
B |
104424 |
| 96253 |
|
B |
104425 |
| 96254 |
|
B |
104426 |
| 96255 |
|
B |
104427 |
| 96256 |
|
B |
104428 |
| 96257 |
|
B |
104429 |
| 96258 |
|
B |
104430 |