Created
October 15, 2021 19:28
-
-
Save kmorozov/5f14b2a329f5e5600c4d137d547d8b93 to your computer and use it in GitHub Desktop.
MySql optimizer trace. With prepared statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "steps": [ | |
| { | |
| "statement_parameters": [ | |
| "LONGLONG", | |
| "LONGLONG" | |
| ] | |
| }, | |
| { | |
| "join_optimization": { | |
| "select#": 1, | |
| "steps": [ | |
| { | |
| "condition_processing": { | |
| "condition": "WHERE", | |
| "original_condition": "((`samples`.`device_id` = 5852) and (`samples`.`device_id` is not null) and (`samples`.`id` <> 188315308))", | |
| "steps": [ | |
| { | |
| "transformation": "equality_propagation", | |
| "resulting_condition": "((5852 is not null) and (`samples`.`id` <> 188315308) and multiple equal(5852, `samples`.`device_id`))" | |
| }, | |
| { | |
| "transformation": "constant_propagation", | |
| "resulting_condition": "((5852 is not null) and (`samples`.`id` <> 188315308) and multiple equal(5852, `samples`.`device_id`))" | |
| }, | |
| { | |
| "transformation": "trivial_condition_removal", | |
| "resulting_condition": "((`samples`.`id` <> 188315308) and multiple equal(5852, `samples`.`device_id`))" | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "substitute_generated_columns": { | |
| } | |
| }, | |
| { | |
| "table_dependencies": [ | |
| { | |
| "table": "`samples`", | |
| "row_may_be_null": false, | |
| "map_bit": 0, | |
| "depends_on_map_bits": [ | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "ref_optimizer_key_uses": [ | |
| { | |
| "table": "`samples`", | |
| "field": "device_id", | |
| "equals": "5852", | |
| "null_rejecting": true | |
| } | |
| ] | |
| }, | |
| { | |
| "rows_estimation": [ | |
| { | |
| "table": "`samples`", | |
| "range_analysis": { | |
| "table_scan": { | |
| "rows": 179018862, | |
| "cost": 1.85e7 | |
| }, | |
| "potential_range_indexes": [ | |
| { | |
| "index": "PRIMARY", | |
| "usable": true, | |
| "key_parts": [ | |
| "id" | |
| ] | |
| }, | |
| { | |
| "index": "samples_organization_id_foreign", | |
| "usable": false, | |
| "cause": "not_applicable" | |
| }, | |
| { | |
| "index": "samples_basestation_id_created_at_index", | |
| "usable": false, | |
| "cause": "not_applicable" | |
| }, | |
| { | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "usable": true, | |
| "key_parts": [ | |
| "device_id", | |
| "created_at", | |
| "organization_id", | |
| "id" | |
| ] | |
| } | |
| ], | |
| "setup_range_conditions": [ | |
| ], | |
| "group_index_range": { | |
| "chosen": false, | |
| "cause": "not_group_by_or_distinct" | |
| }, | |
| "skip_scan_range": { | |
| "potential_skip_scan_indexes": [ | |
| { | |
| "index": "PRIMARY", | |
| "usable": false, | |
| "cause": "query_references_nonkey_column" | |
| }, | |
| { | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "usable": false, | |
| "cause": "query_references_nonkey_column" | |
| } | |
| ] | |
| }, | |
| "analyzing_range_alternatives": { | |
| "range_scan_alternatives": [ | |
| { | |
| "index": "PRIMARY", | |
| "ranges": [ | |
| "id < 188315308", | |
| "188315308 < id" | |
| ], | |
| "index_dives_for_eq_ranges": true, | |
| "rowid_ordered": true, | |
| "using_mrr": false, | |
| "index_only": false, | |
| "rows": 89509436, | |
| "cost": 9.12e6, | |
| "chosen": true | |
| }, | |
| { | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "ranges": [ | |
| "5852 <= device_id <= 5852" | |
| ], | |
| "index_dives_for_eq_ranges": true, | |
| "rowid_ordered": false, | |
| "using_mrr": false, | |
| "index_only": false, | |
| "rows": 647136, | |
| "cost": 550775, | |
| "chosen": true | |
| } | |
| ], | |
| "analyzing_roworder_intersect": { | |
| "usable": false, | |
| "cause": "too_few_roworder_scans" | |
| } | |
| }, | |
| "chosen_range_access_summary": { | |
| "range_access_plan": { | |
| "type": "range_scan", | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "rows": 647136, | |
| "ranges": [ | |
| "5852 <= device_id <= 5852" | |
| ] | |
| }, | |
| "rows_for_plan": 647136, | |
| "cost_for_plan": 550775, | |
| "chosen": true | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "considered_execution_plans": [ | |
| { | |
| "plan_prefix": [ | |
| ], | |
| "table": "`samples`", | |
| "best_access_path": { | |
| "considered_access_paths": [ | |
| { | |
| "access_type": "ref", | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "rows": 647136, | |
| "cost": 550774, | |
| "chosen": true | |
| }, | |
| { | |
| "access_type": "range", | |
| "range_details": { | |
| "used_index": "samples_reverse_device_id_created_at_organization_id_index" | |
| }, | |
| "chosen": false, | |
| "cause": "heuristic_index_cheaper" | |
| } | |
| ] | |
| }, | |
| "condition_filtering_pct": 50, | |
| "rows_for_plan": 323568, | |
| "cost_for_plan": 550774, | |
| "chosen": true | |
| } | |
| ] | |
| }, | |
| { | |
| "attaching_conditions_to_tables": { | |
| "original_condition": "((`samples`.`device_id` = 5852) and (`samples`.`id` <> 188315308))", | |
| "attached_conditions_computation": [ | |
| ], | |
| "attached_conditions_summary": [ | |
| { | |
| "table": "`samples`", | |
| "attached": "((`samples`.`device_id` = 5852) and (`samples`.`id` <> 188315308))" | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "optimizing_distinct_group_by_order_by": { | |
| "simplifying_order_by": { | |
| "original_clause": "`samples`.`created_at` desc", | |
| "items": [ | |
| { | |
| "item": "`samples`.`created_at`" | |
| } | |
| ], | |
| "resulting_clause_is_simple": true, | |
| "resulting_clause": "`samples`.`created_at` desc" | |
| } | |
| } | |
| }, | |
| { | |
| "reconsidering_access_paths_for_index_ordering": { | |
| "clause": "ORDER BY", | |
| "steps": [ | |
| ], | |
| "index_order_summary": { | |
| "table": "`samples`", | |
| "index_provides_order": false, | |
| "order_direction": "undefined", | |
| "index": "samples_reverse_device_id_created_at_organization_id_index", | |
| "plan_changed": false | |
| } | |
| } | |
| }, | |
| { | |
| "finalizing_table_conditions": [ | |
| { | |
| "table": "`samples`", | |
| "original_table_condition": "((`samples`.`device_id` = 5852) and (`samples`.`id` <> 188315308))", | |
| "final_table_condition ": "(`samples`.`id` <> <cache>(188315308))" | |
| } | |
| ] | |
| }, | |
| { | |
| "refine_plan": [ | |
| { | |
| "table": "`samples`", | |
| "pushed_index_condition": "(`samples`.`id` <> <cache>(188315308))", | |
| "table_condition_attached": null | |
| } | |
| ] | |
| }, | |
| { | |
| "considering_tmp_tables": [ | |
| { | |
| "adding_sort_to_table": "samples" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "join_execution": { | |
| "select#": 1, | |
| "steps": [ | |
| { | |
| "sorting_table": "samples", | |
| "filesort_information": [ | |
| { | |
| "direction": "desc", | |
| "expression": "`samples`.`created_at`" | |
| } | |
| ], | |
| "filesort_priority_queue_optimization": { | |
| "limit": 1, | |
| "chosen": true | |
| }, | |
| "filesort_execution": [ | |
| ], | |
| "filesort_summary": { | |
| "memory_available": 262144, | |
| "key_size": 9, | |
| "row_size": 75, | |
| "max_rows_per_buffer": 2, | |
| "num_rows_estimate": 18446744073709551615, | |
| "num_rows_found": 331495, | |
| "num_initial_chunks_spilled_to_disk": 0, | |
| "peak_memory_used": 166, | |
| "sort_algorithm": "std::sort", | |
| "unpacked_addon_fields": "using_priority_queue", | |
| "sort_mode": "<fixed_sort_key, additional_fields>" | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment