Query time 0.00101
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "34.76"
},
"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": 30,
"rows_produced_per_join": 30,
"filtered": "100.00",
"index_condition": "((`nuie_scalesta_net`.`cscart_discussion`.`object_id` in (94764,95565,95567,95568,95570,95572,95573,95576,95577,95582,95583,95584,95585,95586,95639,95654,95934,95937,95941,96206,96207,96208,96601,96604,96605,96607,96609,96611,96614,96615)) and (`nuie_scalesta_net`.`cscart_discussion`.`object_type` = 'P'))",
"cost_info": {
"read_cost": "18.01",
"eval_cost": "3.00",
"prefix_cost": "21.01",
"data_read_per_join": "720"
},
"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": 30,
"filtered": "100.00",
"cost_info": {
"read_cost": "7.50",
"eval_cost": "3.00",
"prefix_cost": "31.51",
"data_read_per_join": "13K"
},
"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": 30,
"filtered": "100.00",
"using_join_buffer": "hash join",
"cost_info": {
"read_cost": "0.25",
"eval_cost": "3.00",
"prefix_cost": "34.76",
"data_read_per_join": "480"
},
"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 |
| 94764 |
|
B |
102936 |
| 95565 |
|
B |
103737 |
| 95567 |
|
B |
103739 |
| 95568 |
|
B |
103740 |
| 95570 |
|
B |
103742 |
| 95572 |
|
B |
103744 |
| 95573 |
|
B |
103745 |
| 95576 |
|
B |
103748 |
| 95577 |
|
B |
103749 |
| 95582 |
|
B |
103754 |
| 95583 |
|
B |
103755 |
| 95584 |
|
B |
103756 |
| 95585 |
|
B |
103757 |
| 95586 |
|
B |
103758 |
| 95639 |
|
B |
103811 |
| 95654 |
|
B |
103826 |
| 95934 |
|
B |
104106 |
| 95937 |
|
B |
104109 |
| 95941 |
|
B |
104113 |
| 96206 |
|
B |
104378 |
| 96207 |
|
B |
104379 |
| 96208 |
|
B |
104380 |
| 96601 |
|
B |
104782 |
| 96604 |
|
B |
104785 |
| 96605 |
|
B |
104786 |
| 96607 |
|
B |
104788 |
| 96609 |
|
B |
104790 |
| 96611 |
|
B |
104792 |
| 96614 |
|
B |
104795 |
| 96615 |
|
B |
104796 |