Query time 0.00095
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 (93495,93496,93497,93498,93499,93500,93501,93502,93503,93504,93505,93506,93507,93508,93509,93510,93511,93512,93513,93514,93529,93530,93531,93532,93533,93534,93535,93536,93537,93538)) 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 |
| 93495 |
|
B |
101635 |
| 93496 |
|
B |
101636 |
| 93497 |
|
B |
101637 |
| 93498 |
|
B |
101638 |
| 93499 |
|
B |
101639 |
| 93500 |
|
B |
101640 |
| 93501 |
|
B |
101641 |
| 93502 |
|
B |
101642 |
| 93503 |
|
B |
101643 |
| 93504 |
|
B |
101644 |
| 93505 |
|
B |
101645 |
| 93506 |
|
B |
101646 |
| 93507 |
|
B |
101647 |
| 93508 |
|
B |
101648 |
| 93509 |
|
B |
101649 |
| 93510 |
|
B |
101650 |
| 93511 |
|
B |
101651 |
| 93512 |
|
B |
101652 |
| 93513 |
|
B |
101653 |
| 93514 |
|
B |
101654 |
| 93529 |
|
B |
101669 |
| 93530 |
|
B |
101670 |
| 93531 |
|
B |
101671 |
| 93532 |
|
B |
101672 |
| 93533 |
|
B |
101673 |
| 93534 |
|
B |
101674 |
| 93535 |
|
B |
101675 |
| 93536 |
|
B |
101676 |
| 93537 |
|
B |
101677 |
| 93538 |
|
B |
101678 |