Query time 0.00946
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "196.51"
},
"grouping_operation": {
"using_filesort": false,
"nested_loop": [
{
"table": {
"table_name": "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": 75,
"rows_produced_per_join": 75,
"filtered": "100.00",
"index_condition": "((`goimagine`.`discussion`.`object_id` in (284648,282838,282836,278049,275782,272636,269248,266156,265783,266092,265784,258086,252518,257589,256790,256001,252277,242304,239493,237409,235920,231091,227946,224968,226497,225207,225304,225273,204337,201932,197488,196621,196622,201889,192454,193258,192450,108385,144425,175093,167561,167552,161993,167239,166202,165403,165290,164900,164913,161865,164905,162133,164899,160627,156319,132617,139306,120811,139394,132610,139524,131992,127555,126324,126318,126321,108204,114844,120905,108233,120730,108232,120456,108246,108180)) and (`goimagine`.`discussion`.`object_type` = 'P'))",
"cost_info": {
"read_cost": "110.93",
"eval_cost": "7.50",
"prefix_cost": "118.43",
"data_read_per_join": "1K"
},
"used_columns": [
"thread_id",
"object_id",
"object_type",
"type"
]
}
},
{
"table": {
"table_name": "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": [
"goimagine.discussion.thread_id",
"const"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 131,
"filtered": "100.00",
"using_index": true,
"cost_info": {
"read_cost": "18.77",
"eval_cost": "13.18",
"prefix_cost": "150.37",
"data_read_per_join": "57K"
},
"used_columns": [
"post_id",
"thread_id",
"status"
]
}
},
{
"table": {
"table_name": "discussion_rating",
"access_type": "eq_ref",
"possible_keys": [
"PRIMARY",
"thread_id"
],
"key": "PRIMARY",
"used_key_parts": [
"post_id"
],
"key_length": "3",
"ref": [
"goimagine.discussion_posts.post_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 131,
"filtered": "100.00",
"cost_info": {
"read_cost": "32.96",
"eval_cost": "13.18",
"prefix_cost": "196.52",
"data_read_per_join": "2K"
},
"used_columns": [
"rating_value",
"post_id",
"thread_id"
],
"attached_condition": "<if>(is_not_null_compl(discussion_rating), ((`goimagine`.`discussion_rating`.`thread_id` = `goimagine`.`discussion`.`thread_id`) and (`goimagine`.`discussion_rating`.`rating_value` <> 0)), true)"
}
}
]
}
}
}
Result
| product_id |
average_rating |
discussion_type |
discussion_thread_id |
| 108180 |
|
D |
744658 |
| 108204 |
|
D |
744687 |
| 108232 |
|
D |
744721 |
| 108233 |
|
D |
744722 |
| 108246 |
|
D |
744735 |
| 108385 |
|
D |
744893 |
| 120456 |
|
D |
776402 |
| 120730 |
|
D |
776711 |
| 120905 |
|
D |
776913 |
| 126318 |
|
D |
782454 |
| 126321 |
|
D |
782458 |
| 126324 |
|
D |
782461 |
| 127555 |
|
D |
783750 |
| 131992 |
|
D |
816763 |
| 132610 |
|
D |
817411 |
| 132617 |
|
D |
817419 |
| 139394 |
|
D |
854098 |
| 139524 |
|
D |
854252 |
| 156319 |
|
D |
1043617 |
| 160627 |
|
D |
1048412 |
| 161865 |
|
D |
1054451 |
| 161993 |
|
D |
1054593 |
| 162133 |
|
D |
1054743 |
| 164899 |
|
D |
1057572 |
| 164900 |
|
D |
1057573 |
| 164913 |
|
D |
1057587 |
| 165403 |
|
D |
1149834 |
| 166202 |
|
D |
1155578 |
| 167239 |
|
D |
1156619 |
| 167552 |
|
D |
1156958 |
| 167561 |
|
D |
1156968 |
| 175093 |
|
D |
1237953 |
| 192450 |
|
D |
1464889 |
| 192454 |
|
D |
1464894 |
| 193258 |
|
D |
1465772 |
| 201889 |
|
D |
1534693 |
| 204337 |
|
D |
1579945 |
| 224968 |
|
D |
1856670 |
| 225207 |
|
D |
1863600 |
| 225273 |
|
D |
1863679 |
| 225304 |
|
D |
1863717 |
| 226497 |
|
D |
1878503 |
| 227946 |
|
D |
1880030 |
| 231091 |
|
D |
1978828 |
| 235920 |
|
D |
1990861 |
| 237409 |
|
D |
1999459 |
| 239493 |
|
D |
2527086 |
| 242304 |
|
D |
2530119 |
| 252277 |
|
D |
2709945 |
| 252518 |
|
D |
2710216 |
| 256001 |
|
D |
3076067 |
| 256790 |
|
D |
3076919 |
| 257589 |
|
D |
3124257 |
| 258086 |
|
D |
3124800 |
| 265783 |
|
D |
3309567 |
| 265784 |
|
D |
3309568 |
| 266092 |
|
D |
3309968 |
| 266156 |
|
D |
3310068 |
| 269248 |
|
D |
3413702 |
| 272636 |
|
D |
3425941 |
| 275782 |
|
D |
3446533 |
| 278049 |
|
D |
3475863 |
| 282838 |
|
D |
3560958 |
| 284648 |
|
D |
3580955 |