Query time 0.00075
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "115.21"
},
"grouping_operation": {
"using_filesort": false,
"nested_loop": [
{
"table": {
"table_name": "cscart_discussion",
"access_type": "range",
"possible_keys": [
"object_id",
"company_id"
],
"key": "object_id",
"used_key_parts": [
"object_id",
"object_type",
"company_id"
],
"key_length": "10",
"rows_examined_per_scan": 24,
"rows_produced_per_join": 24,
"filtered": "100.00",
"index_condition": "((`eshopuga_upgr_4122`.`cscart_discussion`.`company_id` = 1) and (`eshopuga_upgr_4122`.`cscart_discussion`.`object_id` in (1467,1484,1486,1487,1488,1489,1090,1091,1092,1089,1490,1491,962,902,1468,903,1469,1470,1471,1492,1493,1494,1495,1496)) and (`eshopuga_upgr_4122`.`cscart_discussion`.`object_type` = 'P'))",
"cost_info": {
"read_cost": "52.81",
"eval_cost": "4.80",
"prefix_cost": "57.61",
"data_read_per_join": "576"
},
"used_columns": [
"thread_id",
"object_id",
"object_type",
"type",
"company_id"
]
}
},
{
"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": [
"eshopuga_upgr_4122.cscart_discussion.thread_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 24,
"filtered": "100.00",
"cost_info": {
"read_cost": "24.00",
"eval_cost": "4.80",
"prefix_cost": "86.41",
"data_read_per_join": "10K"
},
"used_columns": [
"post_id",
"thread_id",
"status"
],
"attached_condition": "<if>(is_not_null_compl(cscart_discussion_posts), (`eshopuga_upgr_4122`.`cscart_discussion_posts`.`status` = 'A'), true)"
}
},
{
"table": {
"table_name": "cscart_discussion_rating",
"access_type": "eq_ref",
"possible_keys": [
"PRIMARY",
"thread_id"
],
"key": "PRIMARY",
"used_key_parts": [
"post_id"
],
"key_length": "3",
"ref": [
"eshopuga_upgr_4122.cscart_discussion_posts.post_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 24,
"filtered": "100.00",
"cost_info": {
"read_cost": "24.00",
"eval_cost": "4.80",
"prefix_cost": "115.21",
"data_read_per_join": "384"
},
"used_columns": [
"rating_value",
"post_id",
"thread_id"
],
"attached_condition": "<if>(is_not_null_compl(cscart_discussion_rating), ((`eshopuga_upgr_4122`.`cscart_discussion_rating`.`thread_id` = `eshopuga_upgr_4122`.`cscart_discussion`.`thread_id`) and (`eshopuga_upgr_4122`.`cscart_discussion_rating`.`rating_value` <> 0)), true)"
}
}
]
}
}
}
Result
product_id |
average_rating |
discussion_type |
discussion_thread_id |
902 |
|
B |
2909 |
903 |
|
B |
2910 |
962 |
|
B |
2969 |
1089 |
|
B |
3098 |
1090 |
|
B |
3099 |
1091 |
|
B |
3100 |
1092 |
|
B |
3101 |
1467 |
|
B |
3478 |
1468 |
|
B |
3479 |
1469 |
|
B |
3480 |
1470 |
|
B |
3481 |
1471 |
|
B |
3482 |
1484 |
|
B |
3495 |
1486 |
|
B |
3497 |
1487 |
|
B |
3498 |
1488 |
|
B |
3499 |
1489 |
|
B |
3500 |
1490 |
|
B |
3501 |
1491 |
|
B |
3502 |
1492 |
|
B |
3503 |
1493 |
|
B |
3504 |
1494 |
|
B |
3505 |
1495 |
|
B |
3506 |
1496 |
|
B |
3507 |