Query time 0.00099
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 (93197,93198,93199,93200,93201,93202,93203,93204,93205,93206,93207,93208,93209,93210,93211,93212,93213,93214,93215,93216,93217,93218,93219,93220,93221,93222,93223,93224,93225,93226)) 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 |
| 93197 |
|
B |
101337 |
| 93198 |
|
B |
101338 |
| 93199 |
|
B |
101339 |
| 93200 |
|
B |
101340 |
| 93201 |
|
B |
101341 |
| 93202 |
|
B |
101342 |
| 93203 |
|
B |
101343 |
| 93204 |
|
B |
101344 |
| 93205 |
|
B |
101345 |
| 93206 |
|
B |
101346 |
| 93207 |
|
B |
101347 |
| 93208 |
|
B |
101348 |
| 93209 |
|
B |
101349 |
| 93210 |
|
B |
101350 |
| 93211 |
|
B |
101351 |
| 93212 |
|
B |
101352 |
| 93213 |
|
B |
101353 |
| 93214 |
|
B |
101354 |
| 93215 |
|
B |
101355 |
| 93216 |
|
B |
101356 |
| 93217 |
|
B |
101357 |
| 93218 |
|
B |
101358 |
| 93219 |
|
B |
101359 |
| 93220 |
|
B |
101360 |
| 93221 |
|
B |
101361 |
| 93222 |
|
B |
101362 |
| 93223 |
|
B |
101363 |
| 93224 |
|
B |
101364 |
| 93225 |
|
B |
101365 |
| 93226 |
|
B |
101366 |