Query time 0.00113
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 (93584,93585,93586,93587,93588,93589,93590,93591,93592,93593,93594,93595,93596,93597,93598,93599,93600,93601,93602,93603,93604,93605,93606,93607,93608,93609,93610,93611,93612,93613,93614,93615,93616,93617,93618,93619,93620,93621,93622,93623,93624,93625,93626,93627,93628,93629,93630,93631)) 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 |
| 93584 |
|
B |
101724 |
| 93585 |
|
B |
101725 |
| 93586 |
|
B |
101726 |
| 93587 |
|
B |
101727 |
| 93588 |
|
B |
101728 |
| 93589 |
|
B |
101729 |
| 93590 |
|
B |
101730 |
| 93591 |
|
B |
101731 |
| 93592 |
|
B |
101732 |
| 93593 |
|
B |
101733 |
| 93594 |
|
B |
101734 |
| 93595 |
|
B |
101735 |
| 93596 |
|
B |
101736 |
| 93597 |
|
B |
101737 |
| 93598 |
|
B |
101738 |
| 93599 |
|
B |
101739 |
| 93600 |
|
B |
101740 |
| 93601 |
|
B |
101741 |
| 93602 |
|
B |
101742 |
| 93603 |
|
B |
101743 |
| 93604 |
|
B |
101744 |
| 93605 |
|
B |
101745 |
| 93606 |
|
B |
101746 |
| 93607 |
|
B |
101747 |
| 93608 |
|
B |
101748 |
| 93609 |
|
B |
101749 |
| 93610 |
|
B |
101750 |
| 93611 |
|
B |
101751 |
| 93612 |
|
B |
101752 |
| 93613 |
|
B |
101753 |
| 93614 |
|
B |
101754 |
| 93615 |
|
B |
101755 |
| 93616 |
|
B |
101756 |
| 93617 |
|
B |
101757 |
| 93618 |
|
B |
101758 |
| 93619 |
|
B |
101759 |
| 93620 |
|
B |
101760 |
| 93621 |
|
B |
101761 |
| 93622 |
|
B |
101762 |
| 93623 |
|
B |
101763 |
| 93624 |
|
B |
101764 |
| 93625 |
|
B |
101765 |
| 93626 |
|
B |
101766 |
| 93627 |
|
B |
101767 |
| 93628 |
|
B |
101768 |
| 93629 |
|
B |
101769 |
| 93630 |
|
B |
101770 |
| 93631 |
|
B |
101771 |