Query time 0.00101
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 (97137,97138,97139,97140,97141,97142,97143,97144,97145,97146,97147,97148,97149,97150,97151,97152,97153,97154,97155,97156,97157,97158,97159,97160,97161,97162,97163,97164,97165,97166)) 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 |
| 97137 |
|
B |
105318 |
| 97138 |
|
B |
105319 |
| 97139 |
|
B |
105320 |
| 97140 |
|
B |
105321 |
| 97141 |
|
B |
105322 |
| 97142 |
|
B |
105323 |
| 97143 |
|
B |
105324 |
| 97144 |
|
B |
105325 |
| 97145 |
|
B |
105326 |
| 97146 |
|
B |
105327 |
| 97147 |
|
B |
105328 |
| 97148 |
|
B |
105329 |
| 97149 |
|
B |
105330 |
| 97150 |
|
B |
105331 |
| 97151 |
|
B |
105332 |
| 97152 |
|
B |
105333 |
| 97153 |
|
B |
105334 |
| 97154 |
|
B |
105335 |
| 97155 |
|
B |
105336 |
| 97156 |
|
B |
105337 |
| 97157 |
|
B |
105338 |
| 97158 |
|
B |
105339 |
| 97159 |
|
B |
105340 |
| 97160 |
|
B |
105341 |
| 97161 |
|
B |
105342 |
| 97162 |
|
B |
105343 |
| 97163 |
|
B |
105344 |
| 97164 |
|
B |
105345 |
| 97165 |
|
B |
105346 |
| 97166 |
|
B |
105347 |