Query time 0.00110
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 (97252,97253,97254,97255,97256,97257,97258,97259,97260,97261,97262,97263,97264,97265,97266,97267,97268,97269,97270,97271,97272,97273,97274,97275,97276,97277,97278,97279,97280,97281,97282,97283,97284,97285,97286,97287,97288,97289,97290,97291,97292,97293,97294,97295,97296,97297,97298,97299)) 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_2",
"used_key_parts": [
"thread_id",
"status"
],
"key_length": "6",
"ref": [
"nuie_scalesta_net.cscart_discussion.thread_id",
"const"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 48,
"filtered": "100.00",
"using_index": true,
"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"
]
}
},
{
"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 |
| 97252 |
|
B |
105433 |
| 97253 |
|
B |
105434 |
| 97254 |
|
B |
105435 |
| 97255 |
|
B |
105436 |
| 97256 |
|
B |
105437 |
| 97257 |
|
B |
105438 |
| 97258 |
|
B |
105439 |
| 97259 |
|
B |
105440 |
| 97260 |
|
B |
105441 |
| 97261 |
|
B |
105442 |
| 97262 |
|
B |
105443 |
| 97263 |
|
B |
105444 |
| 97264 |
|
B |
105445 |
| 97265 |
|
B |
105446 |
| 97266 |
|
B |
105447 |
| 97267 |
|
B |
105448 |
| 97268 |
|
B |
105449 |
| 97269 |
|
B |
105450 |
| 97270 |
|
B |
105451 |
| 97271 |
|
B |
105452 |
| 97272 |
|
B |
105453 |
| 97273 |
|
B |
105454 |
| 97274 |
|
B |
105455 |
| 97275 |
|
B |
105456 |
| 97276 |
|
B |
105457 |
| 97277 |
|
B |
105458 |
| 97278 |
|
B |
105459 |
| 97279 |
|
B |
105460 |
| 97280 |
|
B |
105461 |
| 97281 |
|
B |
105462 |
| 97282 |
|
B |
105463 |
| 97283 |
|
B |
105464 |
| 97284 |
|
B |
105465 |
| 97285 |
|
B |
105466 |
| 97286 |
|
B |
105467 |
| 97287 |
|
B |
105468 |
| 97288 |
|
B |
105469 |
| 97289 |
|
B |
105470 |
| 97290 |
|
B |
105471 |
| 97291 |
|
B |
105472 |
| 97292 |
|
B |
105473 |
| 97293 |
|
B |
105474 |
| 97294 |
|
B |
105475 |
| 97295 |
|
B |
105476 |
| 97296 |
|
B |
105477 |
| 97297 |
|
B |
105478 |
| 97298 |
|
B |
105479 |
| 97299 |
|
B |
105480 |