Query time 0.05962
JSON explain
{
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "10267.10"
},
"nested_loop": [
{
"table": {
"table_name": "cscart_categories",
"access_type": "const",
"possible_keys": [
"PRIMARY",
"p_category_id",
"idx_categories_storefront_status",
"idx_categories_usergroup_status",
"idx_categories_status_id_path"
],
"key": "PRIMARY",
"used_key_parts": [
"category_id"
],
"key_length": "3",
"ref": [
"const"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 1,
"filtered": "100.00",
"cost_info": {
"read_cost": "0.00",
"eval_cost": "0.10",
"prefix_cost": "0.00",
"data_read_per_join": "2K"
},
"used_columns": [
"category_id",
"status",
"storefront_id"
]
}
},
{
"table": {
"table_name": "products",
"access_type": "range",
"possible_keys": [
"idx_products_composite_query"
],
"key": "idx_products_composite_query",
"used_key_parts": [
"status",
"company_id",
"master_product_status",
"master_product_id",
"parent_product_id"
],
"key_length": "18",
"rows_examined_per_scan": 15774,
"rows_produced_per_join": 6309,
"filtered": "40.00",
"using_index": true,
"cost_info": {
"read_cost": "2568.71",
"eval_cost": "630.91",
"prefix_cost": "3199.62",
"data_read_per_join": "32M"
},
"used_columns": [
"product_id",
"status",
"company_id",
"amount",
"tracking",
"parent_product_id",
"master_product_id",
"master_product_status"
],
"attached_condition": "((`cscart_db`.`products`.`master_product_id` = 0) and (`cscart_db`.`products`.`parent_product_id` = 0) and (`cscart_db`.`products`.`company_id` in (13,0)) and ((`cscart_db`.`products`.`amount` > 0) or (`cscart_db`.`products`.`tracking` = 'D')) and (`cscart_db`.`products`.`status` = 'A') and (`cscart_db`.`products`.`master_product_status` = 'A') and (`cscart_db`.`products`.`company_id` > 0))"
}
},
{
"table": {
"table_name": "companies",
"access_type": "eq_ref",
"possible_keys": [
"PRIMARY"
],
"key": "PRIMARY",
"used_key_parts": [
"company_id"
],
"key_length": "4",
"ref": [
"cscart_db.products.company_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 6309,
"filtered": "100.00",
"cost_info": {
"read_cost": "1577.28",
"eval_cost": "630.91",
"prefix_cost": "5407.81",
"data_read_per_join": "42M"
},
"used_columns": [
"company_id",
"status"
],
"attached_condition": "<if>(found_match(companies), ((`cscart_db`.`companies`.`status` = 'A') or (`cscart_db`.`products`.`company_id` = 0)), true)"
}
},
{
"table": {
"table_name": "products_categories",
"access_type": "ref",
"possible_keys": [
"idx_products_categories_composite"
],
"key": "idx_products_categories_composite",
"used_key_parts": [
"product_id",
"category_id"
],
"key_length": "6",
"ref": [
"cscart_db.products.product_id",
"const"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 6378,
"filtered": "100.00",
"using_index": true,
"cost_info": {
"read_cost": "1988.79",
"eval_cost": "637.89",
"prefix_cost": "8034.49",
"data_read_per_join": "99K"
},
"used_columns": [
"product_id",
"category_id"
]
}
},
{
"table": {
"table_name": "cscart_product_sales",
"access_type": "ref",
"possible_keys": [
"idx_product_sales_category_amount"
],
"key": "idx_product_sales_category_amount",
"used_key_parts": [
"category_id",
"product_id"
],
"key_length": "6",
"ref": [
"const",
"cscart_db.products.product_id"
],
"rows_examined_per_scan": 1,
"rows_produced_per_join": 6378,
"filtered": "100.00",
"using_index": true,
"cost_info": {
"read_cost": "1594.72",
"eval_cost": "637.89",
"prefix_cost": "10267.10",
"data_read_per_join": "99K"
},
"used_columns": [
"category_id",
"product_id"
]
}
}
]
}
}
Result
| COUNT(DISTINCT products.product_id) |
| 0 |