Query time 0.00531
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "61.69"
},
"grouping_operation": {
"using_temporary_table": true,
"using_filesort": true,
"cost_info": {
"sort_cost": "1.05"
},
"nested_loop": [
{
"table": {
"table_name": "jmj_categories",
"access_type": "ALL",
"possible_keys": [
"PRIMARY",
"c_status",
"p_category_id"
],
"rows_examined_per_scan": 120,
"rows_produced_per_join": 4,
"filtered": "4.00",
"cost_info": {
"read_cost": "28.46",
"eval_cost": "0.96",
"prefix_cost": "29.42",
"data_read_per_join": "18K"
},
"used_columns": [
"category_id",
"usergroup_ids",
"status",
"storefront_id"
],
"attached_condition": "((`jmj_test`.`jmj_categories`.`storefront_id` in (0,1)) and ((`jmj_test`.`jmj_categories`.`usergroup_ids` = '') or find_in_set(0,`jmj_test`.`jmj_categories`.`usergroup_ids`) or find_in_set(1,`jmj_test`.`jmj_categories`.`usergroup_ids`)) and (`jmj_test`.`jmj_categories`.`status` in ('A','H')))"
}
},
{
"table": {
"table_name": "jmj_products_categories",
"access_type": "ref",
"possible_keys": [
"PRIMARY",
"pt"
],
"key": "PRIMARY",
"used_key_parts": [
"category_id"
],
"key_length": "3",
"ref": [
"jmj_test.jmj_categories.category_id"
],
"rows_examined_per_scan": 5,
"rows_produced_per_join": 1,
"filtered": "4.39",
"index_condition": "(`jmj_test`.`jmj_products_categories`.`product_id` in (1658,1064,1065,1066,1067,1068,1076,1078,1079,1085,1086,1087,1089,1090,1091,1092,1093,1094,1096,1097,1098,1148,1573))",
"cost_info": {
"read_cost": "25.15",
"eval_cost": "0.21",
"prefix_cost": "59.37",
"data_read_per_join": "16"
},
"used_columns": [
"product_id",
"category_id",
"link_type"
]
}
},
{
"table": {
"table_name": "product_position_source",
"access_type": "eq_ref",
"possible_keys": [
"PRIMARY",
"pt"
],
"key": "PRIMARY",
"used_key_parts": [
"category_id",
"product_id"
],
"key_length": "6",
"ref": [
"const",
"jmj_test.jmj_products_categories.product_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 1,
"filtered": "100.00",
"cost_info": {
"read_cost": "1.05",
"eval_cost": "0.21",
"prefix_cost": "60.64",
"data_read_per_join": "16"
},
"used_columns": [
"product_id",
"category_id",
"position"
]
}
}
]
}
}
}
Result
| product_id |
category_ids |
position |
| 1064 |
83M |
0 |
| 1065 |
83M |
0 |
| 1066 |
83M |
0 |
| 1067 |
83M |
0 |
| 1068 |
83M |
0 |
| 1076 |
83M |
0 |
| 1078 |
83M |
0 |
| 1079 |
83M |
0 |
| 1085 |
83M |
0 |
| 1086 |
83M |
0 |
| 1087 |
83M |
0 |
| 1089 |
83M |
0 |
| 1090 |
83M |
0 |
| 1091 |
83M |
0 |
| 1092 |
83M |
0 |
| 1093 |
83M |
0 |
| 1094 |
83M |
0 |
| 1096 |
83M |
0 |
| 1097 |
83M |
0 |
| 1098 |
83M |
0 |
| 1148 |
83M |
0 |
| 1573 |
83M |
0 |
| 1658 |
83M |
0 |