Query time 0.00093
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 (96332,96335,96339,97016,97022,97023,97026,97030,97032,97039,97045,97833,97843,97847,97852,97856,97860,97864,97868,97872,97890,97891,97892,97893,97894,97895,97896,97897,97898,97899)) 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 |
| 96332 |
|
B |
104504 |
| 96335 |
|
B |
104507 |
| 96339 |
|
B |
104511 |
| 97016 |
|
B |
105197 |
| 97022 |
|
B |
105203 |
| 97023 |
|
B |
105204 |
| 97026 |
|
B |
105207 |
| 97030 |
|
B |
105211 |
| 97032 |
|
B |
105213 |
| 97039 |
|
B |
105220 |
| 97045 |
|
B |
105226 |
| 97833 |
|
B |
106014 |
| 97843 |
|
B |
106024 |
| 97847 |
|
B |
106028 |
| 97852 |
|
B |
106033 |
| 97856 |
|
B |
106037 |
| 97860 |
|
B |
106041 |
| 97864 |
|
B |
106045 |
| 97868 |
|
B |
106049 |
| 97872 |
|
B |
106053 |
| 97890 |
|
B |
106071 |
| 97891 |
|
B |
106072 |
| 97892 |
|
B |
106073 |
| 97893 |
|
B |
106074 |
| 97894 |
|
B |
106075 |
| 97895 |
|
B |
106076 |
| 97896 |
|
B |
106077 |
| 97897 |
|
B |
106078 |
| 97898 |
|
B |
106079 |
| 97899 |
|
B |
106080 |