Query time 0.00097
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 (95896,95897,95898,95899,95900,95901,95902,95903,95904,95905,95906,95907,95908,95909,95910,95911,95912,95913,95914,95915,95916,95917,95918,95919,95920,95921,95922,95923,95924,95945)) 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 |
| 95896 |
|
B |
104068 |
| 95897 |
|
B |
104069 |
| 95898 |
|
B |
104070 |
| 95899 |
|
B |
104071 |
| 95900 |
|
B |
104072 |
| 95901 |
|
B |
104073 |
| 95902 |
|
B |
104074 |
| 95903 |
|
B |
104075 |
| 95904 |
|
B |
104076 |
| 95905 |
|
B |
104077 |
| 95906 |
|
B |
104078 |
| 95907 |
|
B |
104079 |
| 95908 |
|
B |
104080 |
| 95909 |
|
B |
104081 |
| 95910 |
|
B |
104082 |
| 95911 |
|
B |
104083 |
| 95912 |
|
B |
104084 |
| 95913 |
|
B |
104085 |
| 95914 |
|
B |
104086 |
| 95915 |
|
B |
104087 |
| 95916 |
|
B |
104088 |
| 95917 |
|
B |
104089 |
| 95918 |
|
B |
104090 |
| 95919 |
|
B |
104091 |
| 95920 |
|
B |
104092 |
| 95921 |
|
B |
104093 |
| 95922 |
|
B |
104094 |
| 95923 |
|
B |
104095 |
| 95924 |
|
B |
104096 |
| 95945 |
|
B |
104117 |