QUERY: select distinct svc.idService, svc.deviceUID, svc.driverId, svc.lineId, svc.subLineId, svc.initDateTime, svc.endDateTime, svc.originStopId, svc.reinforcement, sd.hardwareId as vehicleIdentificationNumber from iots.Service svc inner join iots.ServiceData sd on svc.idService = sd.idService and svc.deviceUID = sd.deviceUID inner join drivers.drivers d on d.code = svc.driverId where ((svc.initDateTime between '2025-02-11' and '2025-02-12') or (svc.endDateTime between '2025-02-11' and '2025-02-12')) and d.company_id in (51) TRACE: { "steps": [ { "join_preparation": { "select_id": 1, "steps": [ { "expanded_query": "select distinct iots.svc.idService AS idService,iots.svc.deviceUID AS deviceUID,iots.svc.driverId AS driverId,iots.svc.lineId AS lineId,iots.svc.subLineId AS subLineId,iots.svc.initDateTime AS initDateTime,iots.svc.endDateTime AS endDateTime,iots.svc.originStopId AS originStopId,iots.svc.reinforcement AS reinforcement,iots.sd.hardwareId AS vehicleIdentificationNumber from ((Service svc join ServiceData sd on(iots.svc.idService = iots.sd.idService and iots.svc.deviceUID = iots.sd.deviceUID)) join drivers d on(drivers.d.`code` = iots.svc.driverId)) where (iots.svc.initDateTime between <cache>('2025-02-11') and <cache>('2025-02-12') or iots.svc.endDateTime between <cache>('2025-02-11') and <cache>('2025-02-12')) and drivers.d.company_id = 51" } ] } }, { "join_optimization": { "select_id": 1, "steps": [ { "condition_processing": { "condition": "WHERE", "original_condition": "(iots.svc.initDateTime between <cache>('2025-02-11') and <cache>('2025-02-12') or iots.svc.endDateTime between <cache>('2025-02-11') and <cache>('2025-02-12')) and drivers.d.company_id = 51 and drivers.d.`code` = iots.svc.driverId and iots.svc.idService = iots.sd.idService and iots.svc.deviceUID = iots.sd.deviceUID", "steps": [ { "transformation": "equality_propagation", "resulting_condition": "(iots.svc.initDateTime between <cache>('2025-02-11') and <cache>('2025-02-12') or iots.svc.endDateTime between <cache>('2025-02-11') and <cache>('2025-02-12')) and drivers.d.`code` = iots.svc.driverId and iots.svc.deviceUID = iots.sd.deviceUID and multiple equal(51, drivers.d.company_id) and multiple equal(iots.svc.idService, iots.sd.idService)" }, { "transformation": "constant_propagation", "resulting_condition": "(iots.svc.initDateTime between <cache>('2025-02-11') and <cache>('2025-02-12') or iots.svc.endDateTime between <cache>('2025-02-11') and <cache>('2025-02-12')) and drivers.d.`code` = iots.svc.driverId and iots.svc.deviceUID = iots.sd.deviceUID and multiple equal(51, drivers.d.company_id) and multiple equal(iots.svc.idService, iots.sd.idService)" }, { "transformation": "trivial_condition_removal", "resulting_condition": "(iots.svc.initDateTime between <cache>('2025-02-11') and <cache>('2025-02-12') or iots.svc.endDateTime between <cache>('2025-02-11') and <cache>('2025-02-12')) and drivers.d.`code` = iots.svc.driverId and iots.svc.deviceUID = iots.sd.deviceUID and multiple equal(51, drivers.d.company_id) and multiple equal(iots.svc.idService, iots.sd.idService)" } ] } }, { "table_dependencies": [ { "table": "svc", "row_may_be_null": false, "map_bit": 0, "depends_on_map_bits": [] }, { "table": "sd", "row_may_be_null": false, "map_bit": 1, "depends_on_map_bits": [] }, { "table": "d", "row_may_be_null": false, "map_bit": 2, "depends_on_map_bits": [] } ] }, { "ref_optimizer_key_uses": [ { "table": "svc", "field": "idService", "equals": "iots.sd.idService", "null_rejecting": false }, { "table": "svc", "field": "deviceUID", "equals": "iots.sd.deviceUID", "null_rejecting": false }, { "table": "sd", "field": "idService", "equals": "iots.svc.idService", "null_rejecting": false }, { "table": "sd", "field": "deviceUID", "equals": "iots.svc.deviceUID", "null_rejecting": false }, { "table": "d", "field": "company_id", "equals": "51", "null_rejecting": false }, { "table": "d", "field": "company_id", "equals": "51", "null_rejecting": false } ] }, { "rows_estimation": [ { "table": "svc", "range_analysis": { "table_scan": { "rows": 2383168, "cost": 488720.6 }, "potential_range_indexes": [ { "index": "PRIMARY", "usable": false, "cause": "not applicable" }, { "index": "IDX_init_end_Service", "usable": true, "key_parts": [ "initDateTime", "endDateTime", "idService", "deviceUID" ] } ], "setup_range_conditions": [], "analyzing_range_alternatives": { "range_scan_alternatives": [], "analyzing_roworder_intersect": { "cause": "too few roworder scans" }, "analyzing_index_merge_union": [] }, "group_index_range": { "chosen": false, "cause": "not single_table" } } }, { "selectivity_for_indexes": [], "selectivity_for_columns": [], "cond_selectivity": 1 }, { "table": "sd", "table_scan": { "rows": 2383155, "cost": 6956 } }, { "table": "d", "range_analysis": { "table_scan": { "rows": 3143, "cost": 651.6 }, "potential_range_indexes": [ { "index": "PRIMARY", "usable": false, "cause": "not applicable" }, { "index": "unique_driver_document", "usable": true, "key_parts": ["company_id", "doc_number"] }, { "index": "IDX_companyId_drivers", "usable": true, "key_parts": ["company_id", "code"] } ], "best_covering_index_scan": { "index": "IDX_companyId_drivers", "cost": 640.0485688, "chosen": true }, "setup_range_conditions": [], "analyzing_range_alternatives": { "range_scan_alternatives": [ { "index": "unique_driver_document", "ranges": ["(51) <= (company_id) <= (51)"], "rowid_ordered": false, "using_mrr": false, "index_only": true, "rows": 408, "cost": 82.04380989, "chosen": true }, { "index": "IDX_companyId_drivers", "ranges": ["(51) <= (company_id) <= (51)"], "rowid_ordered": true, "using_mrr": false, "index_only": true, "rows": 408, "cost": 81.93424626, "chosen": true } ], "analyzing_roworder_intersect": { "cause": "too few roworder scans" }, "analyzing_index_merge_union": [] }, "group_index_range": { "chosen": false, "cause": "not single_table" }, "chosen_range_access_summary": { "range_access_plan": { "type": "range_scan", "index": "IDX_companyId_drivers", "rows": 408, "ranges": ["(51) <= (company_id) <= (51)"] }, "rows_for_plan": 408, "cost_for_plan": 81.93424626, "chosen": true } } }, { "table": "d", "rowid_filters": [ { "key": "IDX_companyId_drivers", "build_cost": 26.88021633, "rows": 408 }, { "key": "IDX_companyId_drivers", "build_cost": 26.88021633, "rows": 408 } ] }, { "selectivity_for_indexes": [ { "index_name": "unique_driver_document", "selectivity_from_index": 0.129812281 } ], "selectivity_for_columns": [], "cond_selectivity": 0.129812281 } ] }, { "considered_execution_plans": [ { "plan_prefix": [], "table": "d", "best_access_path": { "considered_access_paths": [ { "access_type": "ref", "index": "unique_driver_document", "used_range_estimates": true, "rowid_filter_skipped": "worst/max seeks clipping", "rows": 408, "cost": 0.423809887, "chosen": true }, { "access_type": "ref", "index": "IDX_companyId_drivers", "used_range_estimates": true, "rowid_filter_skipped": "worst/max seeks clipping", "rows": 408, "cost": 0.314246262, "chosen": true }, { "type": "scan", "chosen": false, "cause": "cost" } ], "chosen_access_method": { "type": "ref", "records": 408, "cost": 0.314246262, "uses_join_buffering": false } }, "rows_for_plan": 408, "cost_for_plan": 81.91424626, "rest_of_plan": [ { "plan_prefix": ["d"], "table": "sd", "best_access_path": { "considered_access_paths": [ { "access_type": "scan", "resulting_rows": 2383155, "cost": 6956, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 2383155, "cost": 6956, "uses_join_buffering": true } }, "rows_for_plan": 972327240, "cost_for_plan": 194472485.9, "rest_of_plan": [ { "plan_prefix": ["d", "sd"], "table": "svc", "best_access_path": { "considered_access_paths": [ { "access_type": "eq_ref", "index": "PRIMARY", "rows": 1, "cost": 2383155, "chosen": true }, { "access_type": "scan", "resulting_rows": 2383168, "cost": 2958444255, "chosen": false } ], "chosen_access_method": { "type": "eq_ref", "records": 1, "cost": 2383155, "uses_join_buffering": false } }, "rows_for_plan": 972327240, "cost_for_plan": 391321088.9, "pruned_by_hanging_leaf": true } ] }, { "plan_prefix": ["d"], "table": "svc", "best_access_path": { "considered_access_paths": [ { "access_type": "scan", "resulting_rows": 2383168, "cost": 12085, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 2383168, "cost": 12085, "uses_join_buffering": true } }, "rows_for_plan": 972332544, "cost_for_plan": 194478675.7, "rest_of_plan": [ { "plan_prefix": ["d", "svc"], "table": "sd", "best_access_path": { "considered_access_paths": [ { "access_type": "eq_ref", "index": "PRIMARY", "rows": 1, "cost": 2383168, "chosen": true }, { "access_type": "scan", "resulting_rows": 2383155, "cost": 2218880528, "chosen": false } ], "chosen_access_method": { "type": "eq_ref", "records": 1, "cost": 2383168, "uses_join_buffering": false } }, "rows_for_plan": 972332544, "cost_for_plan": 391328352.5, "pruned_by_cost": true } ] } ] }, { "plan_prefix": [], "table": "sd", "best_access_path": { "considered_access_paths": [ { "access_type": "scan", "resulting_rows": 2383155, "cost": 6956, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 2383155, "cost": 6956, "uses_join_buffering": false } }, "rows_for_plan": 2383155, "cost_for_plan": 483587, "pruned_by_heuristic": true }, { "plan_prefix": [], "table": "svc", "best_access_path": { "considered_access_paths": [ { "access_type": "scan", "resulting_rows": 2383168, "cost": 12085, "chosen": true } ], "chosen_access_method": { "type": "scan", "records": 2383168, "cost": 12085, "uses_join_buffering": false } }, "rows_for_plan": 2383168, "cost_for_plan": 488718.6, "pruned_by_heuristic": true } ] }, { "best_join_order": ["d", "sd", "svc"] }, { "substitute_best_equal": { "condition": "WHERE", "resulting_condition": "drivers.d.company_id = 51 and iots.svc.idService = iots.sd.idService and (iots.svc.initDateTime between '2025-02-11 00:00:00.000000' and '2025-02-12 00:00:00.000000' or iots.svc.endDateTime between '2025-02-11 00:00:00.000000' and '2025-02-12 00:00:00.000000') and drivers.d.`code` = iots.svc.driverId and iots.svc.deviceUID = iots.sd.deviceUID" } }, { "attaching_conditions_to_tables": { "attached_conditions_computation": [], "attached_conditions_summary": [ { "table": "d", "attached": null }, { "table": "sd", "attached": null }, { "table": "svc", "attached": "(iots.svc.initDateTime between '2025-02-11 00:00:00.000000' and '2025-02-12 00:00:00.000000' or iots.svc.endDateTime between '2025-02-11 00:00:00.000000' and '2025-02-12 00:00:00.000000') and drivers.d.`code` = iots.svc.driverId and iots.svc.deviceUID = iots.sd.deviceUID" } ] } } ] } }, { "join_execution": { "select_id": 1, "steps": [] } } ] } MISSING_BYTES_BEYOND_MAX_MEM_SIZE: 0 INSUFFICIENT_PRIVILEGES: 0 1 row in set (0.001 sec)