select * from events_new_distr e join profiles p on e.profile_id = p.id where event_date between '2016-01-01' and '2016-01-01' + interval 15 day and status = 'active' and profile_id in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16) order by event_date desc limit 10 {\ "steps": [\ {\ "join_preparation": {\ "select#": 1,\ "steps": [\ {\ "IN_uses_bisection": true\ },\ {\ "expanded_query": "/* select#1 */ select `e`.`id` AS `id`,`e`.`event_date` AS `event_date`,`e`.`profile_id` AS `profile_id`,`p`.`id` AS `id`,`p`.`email` AS `email`,`p`.`status` AS `status` from (`events_new_distr` `e` join `profiles` `p` on((`e`.`profile_id` = `p`.`id`))) where ((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`p`.`status` = 'active') and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16))) order by `e`.`event_date` desc limit 10"\ },\ {\ "transformations_to_nested_joins": {\ "transformations": [\ "JOIN_condition_to_WHERE",\ "parenthesis_removal"\ ] /* transformations */,\ "expanded_query": "/* select#1 */ select `e`.`id` AS `id`,`e`.`event_date` AS `event_date`,`e`.`profile_id` AS `profile_id`,`p`.`id` AS `id`,`p`.`email` AS `email`,`p`.`status` AS `status` from `events_new_distr` `e` join `profiles` `p` where ((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`p`.`status` = 'active') and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)) and (`e`.`profile_id` = `p`.`id`)) order by `e`.`event_date` desc limit 10"\ } /* transformations_to_nested_joins */\ }\ ] /* steps */\ } /* join_preparation */\ },\ {\ "join_optimization": {\ "select#": 1,\ "steps": [\ {\ "condition_processing": {\ "condition": "WHERE",\ "original_condition": "((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`p`.`status` = 'active') and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)) and (`e`.`profile_id` = `p`.`id`))",\ "steps": [\ {\ "transformation": "equality_propagation",\ "resulting_condition": "((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)) and multiple equal('active', `p`.`status`) and multiple equal(`e`.`profile_id`, `p`.`id`))"\ },\ {\ "transformation": "constant_propagation",\ "resulting_condition": "((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)) and multiple equal('active', `p`.`status`) and multiple equal(`e`.`profile_id`, `p`.`id`))"\ },\ {\ "transformation": "trivial_condition_removal",\ "resulting_condition": "((`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`e`.`profile_id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)) and multiple equal('active', `p`.`status`) and multiple equal(`e`.`profile_id`, `p`.`id`))"\ }\ ] /* steps */\ } /* condition_processing */\ },\ {\ "substitute_generated_columns": {\ } /* substitute_generated_columns */\ },\ {\ "table_dependencies": [\ {\ "table": "`events_new_distr` `e`",\ "row_may_be_null": false,\ "map_bit": 0,\ "depends_on_map_bits": [\ ] /* depends_on_map_bits */\ },\ {\ "table": "`profiles` `p`",\ "row_may_be_null": false,\ "map_bit": 1,\ "depends_on_map_bits": [\ ] /* depends_on_map_bits */\ }\ ] /* table_dependencies */\ },\ {\ "ref_optimizer_key_uses": [\ {\ "table": "`events_new_distr` `e`",\ "field": "profile_id",\ "equals": "`p`.`id`",\ "null_rejecting": false\ },\ {\ "table": "`events_new_distr` `e`",\ "field": "profile_id",\ "equals": "`p`.`id`",\ "null_rejecting": false\ },\ {\ "table": "`profiles` `p`",\ "field": "id",\ "equals": "`e`.`profile_id`",\ "null_rejecting": true\ }\ ] /* ref_optimizer_key_uses */\ },\ {\ "rows_estimation": [\ {\ "table": "`events_new_distr` `e`",\ "range_analysis": {\ "table_scan": {\ "rows": 55133746,\ "cost": 1.11e7\ } /* table_scan */,\ "potential_range_indexes": [\ {\ "index": "PRIMARY",\ "usable": false,\ "cause": "not_applicable"\ },\ {\ "index": "profile_id",\ "usable": true,\ "key_parts": [\ "profile_id",\ "id"\ ] /* key_parts */\ },\ {\ "index": "event_date",\ "usable": true,\ "key_parts": [\ "event_date",\ "id"\ ] /* key_parts */\ },\ {\ "index": "comb",\ "usable": true,\ "key_parts": [\ "profile_id",\ "event_date",\ "id"\ ] /* key_parts */\ }\ ] /* potential_range_indexes */,\ "best_covering_index_scan": {\ "index": "comb",\ "cost": 1.11e7,\ "chosen": true\ } /* best_covering_index_scan */,\ "setup_range_conditions": [\ ] /* setup_range_conditions */,\ "group_index_range": {\ "chosen": false,\ "cause": "not_single_table"\ } /* group_index_range */,\ "analyzing_range_alternatives": {\ "range_scan_alternatives": [\ {\ "index": "profile_id",\ "ranges": [\ "1 <= profile_id <= 1",\ "2 <= profile_id <= 2",\ "4 <= profile_id <= 4",\ "5 <= profile_id <= 5",\ "6 <= profile_id <= 6",\ "7 <= profile_id <= 7",\ "8 <= profile_id <= 8",\ "9 <= profile_id <= 9",\ "10 <= profile_id <= 10",\ "11 <= profile_id <= 11",\ "12 <= profile_id <= 12",\ "13 <= profile_id <= 13",\ "14 <= profile_id <= 14",\ "15 <= profile_id <= 15",\ "16 <= profile_id <= 16"\ ] /* ranges */,\ "index_dives_for_eq_ranges": true,\ "rowid_ordered": false,\ "using_mrr": false,\ "index_only": false,\ "rows": 27566917,\ "cost": 3.31e7,\ "chosen": false,\ "cause": "cost"\ },\ {\ "index": "event_date",\ "ranges": [\ "0x9998420000 <= event_date <= 0x9998600000"\ ] /* ranges */,\ "index_dives_for_eq_ranges": true,\ "rowid_ordered": false,\ "using_mrr": false,\ "index_only": false,\ "rows": 1703196,\ "cost": 2.04e6,\ "chosen": true\ },\ {\ "index": "comb",\ "ranges": [\ "1 <= profile_id <= 1 AND 0x9998420000 <= event_date <= 0x9998600000",\ "2 <= profile_id <= 2 AND 0x9998420000 <= event_date <= 0x9998600000",\ "4 <= profile_id <= 4 AND 0x9998420000 <= event_date <= 0x9998600000",\ "5 <= profile_id <= 5 AND 0x9998420000 <= event_date <= 0x9998600000",\ "6 <= profile_id <= 6 AND 0x9998420000 <= event_date <= 0x9998600000",\ "7 <= profile_id <= 7 AND 0x9998420000 <= event_date <= 0x9998600000",\ "8 <= profile_id <= 8 AND 0x9998420000 <= event_date <= 0x9998600000",\ "9 <= profile_id <= 9 AND 0x9998420000 <= event_date <= 0x9998600000",\ "10 <= profile_id <= 10 AND 0x9998420000 <= event_date <= 0x9998600000",\ "11 <= profile_id <= 11 AND 0x9998420000 <= event_date <= 0x9998600000",\ "12 <= profile_id <= 12 AND 0x9998420000 <= event_date <= 0x9998600000",\ "13 <= profile_id <= 13 AND 0x9998420000 <= event_date <= 0x9998600000",\ "14 <= profile_id <= 14 AND 0x9998420000 <= event_date <= 0x9998600000",\ "15 <= profile_id <= 15 AND 0x9998420000 <= event_date <= 0x9998600000",\ "16 <= profile_id <= 16 AND 0x9998420000 <= event_date <= 0x9998600000"\ ] /* ranges */,\ "index_dives_for_eq_ranges": true,\ "rowid_ordered": false,\ "using_mrr": false,\ "index_only": true,\ "rows": 1776830,\ "cost": 358615,\ "chosen": true\ }\ ] /* range_scan_alternatives */,\ "analyzing_roworder_intersect": {\ "usable": false,\ "cause": "too_few_roworder_scans"\ } /* analyzing_roworder_intersect */\ } /* analyzing_range_alternatives */,\ "chosen_range_access_summary": {\ "range_access_plan": {\ "type": "range_scan",\ "index": "comb",\ "rows": 1776830,\ "ranges": [\ "1 <= profile_id <= 1 AND 0x9998420000 <= event_date <= 0x9998600000",\ "2 <= profile_id <= 2 AND 0x9998420000 <= event_date <= 0x9998600000",\ "4 <= profile_id <= 4 AND 0x9998420000 <= event_date <= 0x9998600000",\ "5 <= profile_id <= 5 AND 0x9998420000 <= event_date <= 0x9998600000",\ "6 <= profile_id <= 6 AND 0x9998420000 <= event_date <= 0x9998600000",\ "7 <= profile_id <= 7 AND 0x9998420000 <= event_date <= 0x9998600000",\ "8 <= profile_id <= 8 AND 0x9998420000 <= event_date <= 0x9998600000",\ "9 <= profile_id <= 9 AND 0x9998420000 <= event_date <= 0x9998600000",\ "10 <= profile_id <= 10 AND 0x9998420000 <= event_date <= 0x9998600000",\ "11 <= profile_id <= 11 AND 0x9998420000 <= event_date <= 0x9998600000",\ "12 <= profile_id <= 12 AND 0x9998420000 <= event_date <= 0x9998600000",\ "13 <= profile_id <= 13 AND 0x9998420000 <= event_date <= 0x9998600000",\ "14 <= profile_id <= 14 AND 0x9998420000 <= event_date <= 0x9998600000",\ "15 <= profile_id <= 15 AND 0x9998420000 <= event_date <= 0x9998600000",\ "16 <= profile_id <= 16 AND 0x9998420000 <= event_date <= 0x9998600000"\ ] /* ranges */\ } /* range_access_plan */,\ "rows_for_plan": 1776830,\ "cost_for_plan": 358615,\ "chosen": true\ } /* chosen_range_access_summary */\ } /* range_analysis */\ },\ {\ "table": "`profiles` `p`",\ "range_analysis": {\ "table_scan": {\ "rows": 33499,\ "cost": 6798.9\ } /* table_scan */,\ "potential_range_indexes": [\ {\ "index": "PRIMARY",\ "usable": true,\ "key_parts": [\ "id"\ ] /* key_parts */\ },\ {\ "index": "email",\ "usable": false,\ "cause": "not_applicable"\ }\ ] /* potential_range_indexes */,\ "setup_range_conditions": [\ ] /* setup_range_conditions */,\ "group_index_range": {\ "chosen": false,\ "cause": "not_single_table"\ } /* group_index_range */,\ "analyzing_range_alternatives": {\ "range_scan_alternatives": [\ {\ "index": "PRIMARY",\ "ranges": [\ "1 <= id <= 1",\ "2 <= id <= 2",\ "4 <= id <= 4",\ "5 <= id <= 5",\ "6 <= id <= 6",\ "7 <= id <= 7",\ "8 <= id <= 8",\ "9 <= id <= 9",\ "10 <= id <= 10",\ "11 <= id <= 11",\ "12 <= id <= 12",\ "13 <= id <= 13",\ "14 <= id <= 14",\ "15 <= id <= 15",\ "16 <= id <= 16"\ ] /* ranges */,\ "index_dives_for_eq_ranges": true,\ "rowid_ordered": true,\ "using_mrr": false,\ "index_only": false,\ "rows": 15,\ "cost": 18.027,\ "chosen": true\ }\ ] /* range_scan_alternatives */,\ "analyzing_roworder_intersect": {\ "usable": false,\ "cause": "too_few_roworder_scans"\ } /* analyzing_roworder_intersect */\ } /* analyzing_range_alternatives */,\ "chosen_range_access_summary": {\ "range_access_plan": {\ "type": "range_scan",\ "index": "PRIMARY",\ "rows": 15,\ "ranges": [\ "1 <= id <= 1",\ "2 <= id <= 2",\ "4 <= id <= 4",\ "5 <= id <= 5",\ "6 <= id <= 6",\ "7 <= id <= 7",\ "8 <= id <= 8",\ "9 <= id <= 9",\ "10 <= id <= 10",\ "11 <= id <= 11",\ "12 <= id <= 12",\ "13 <= id <= 13",\ "14 <= id <= 14",\ "15 <= id <= 15",\ "16 <= id <= 16"\ ] /* ranges */\ } /* range_access_plan */,\ "rows_for_plan": 15,\ "cost_for_plan": 18.027,\ "chosen": true\ } /* chosen_range_access_summary */\ } /* range_analysis */\ }\ ] /* rows_estimation */\ },\ {\ "considered_execution_plans": [\ {\ "plan_prefix": [\ ] /* plan_prefix */,\ "table": "`profiles` `p`",\ "best_access_path": {\ "considered_access_paths": [\ {\ "access_type": "ref",\ "index": "PRIMARY",\ "usable": false,\ "chosen": false\ },\ {\ "rows_to_scan": 15,\ "access_type": "range",\ "range_details": {\ "used_index": "PRIMARY"\ } /* range_details */,\ "resulting_rows": 1.5,\ "cost": 21.027,\ "chosen": true\ }\ ] /* considered_access_paths */\ } /* best_access_path */,\ "condition_filtering_pct": 100,\ "rows_for_plan": 1.5,\ "cost_for_plan": 21.027,\ "rest_of_plan": [\ {\ "plan_prefix": [\ "`profiles` `p`"\ ] /* plan_prefix */,\ "table": "`events_new_distr` `e`",\ "best_access_path": {\ "considered_access_paths": [\ {\ "access_type": "ref",\ "index": "profile_id",\ "rows": 29674,\ "cost": 53413,\ "chosen": true\ },\ {\ "access_type": "ref",\ "index": "comb",\ "rows": 29658,\ "cost": 8980.1,\ "chosen": true\ },\ {\ "access_type": "range",\ "range_details": {\ "used_index": "comb"\ } /* range_details */,\ "cost": 713981,\ "rows": 1776830,\ "chosen": false,\ "cause": "cost"\ }\ ] /* considered_access_paths */\ } /* best_access_path */,\ "condition_filtering_pct": 3.0892,\ "rows_for_plan": 1374.3,\ "cost_for_plan": 9001.2,\ "sort_cost": 1374.3,\ "new_cost_for_plan": 10375,\ "chosen": true\ }\ ] /* rest_of_plan */\ },\ {\ "plan_prefix": [\ ] /* plan_prefix */,\ "table": "`events_new_distr` `e`",\ "best_access_path": {\ "considered_access_paths": [\ {\ "access_type": "ref",\ "index": "profile_id",\ "usable": false,\ "chosen": false\ },\ {\ "access_type": "ref",\ "index": "comb",\ "usable": false,\ "chosen": false\ },\ {\ "rows_to_scan": 1776830,\ "access_type": "range",\ "range_details": {\ "used_index": "comb"\ } /* range_details */,\ "resulting_rows": 1.78e6,\ "cost": 713981,\ "chosen": true\ }\ ] /* considered_access_paths */\ } /* best_access_path */,\ "condition_filtering_pct": 100,\ "rows_for_plan": 1.78e6,\ "cost_for_plan": 713981,\ "pruned_by_cost": true\ }\ ] /* considered_execution_plans */\ },\ {\ "attaching_conditions_to_tables": {\ "original_condition": "((`e`.`profile_id` = `p`.`id`) and (`p`.`status` = 'active') and (`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day)) and (`p`.`id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)))",\ "attached_conditions_computation": [\ ] /* attached_conditions_computation */,\ "attached_conditions_summary": [\ {\ "table": "`profiles` `p`",\ "attached": "((`p`.`status` = 'active') and (`p`.`id` in (1,2,4,5,6,7,8,9,10,11,12,13,14,15,16)))"\ },\ {\ "table": "`events_new_distr` `e`",\ "attached": "(`e`.`event_date` between '2016-01-01' and ('2016-01-01' + interval 15 day))"\ }\ ] /* attached_conditions_summary */\ } /* attaching_conditions_to_tables */\ },\ {\ "clause_processing": {\ "clause": "ORDER BY",\ "original_clause": "`e`.`event_date` desc",\ "items": [\ {\ "item": "`e`.`event_date`"\ }\ ] /* items */,\ "resulting_clause_is_simple": false,\ "resulting_clause": "`e`.`event_date` desc"\ } /* clause_processing */\ },\ {\ "refine_plan": [\ {\ "table": "`profiles` `p`"\ },\ {\ "table": "`events_new_distr` `e`"\ }\ ] /* refine_plan */\ }\ ] /* steps */\ } /* join_optimization */\ },\ {\ "join_execution": {\ "select#": 1,\ "steps": [\ {\ "creating_tmp_table": {\ "tmp_table_info": {\ "table": "intermediate_tmp_table",\ "row_length": 375,\ "key_length": 0,\ "unique_constraint": false,\ "location": "memory (heap)",\ "row_limit_estimate": 44739\ } /* tmp_table_info */\ } /* creating_tmp_table */\ },\ {\ "converting_tmp_table_to_ondisk": {\ "cause": "memory_table_size_exceeded",\ "tmp_table_info": {\ "table": "intermediate_tmp_table",\ "row_length": 375,\ "key_length": 0,\ "unique_constraint": false,\ "location": "disk (InnoDB)",\ "record_format": "packed"\ } /* tmp_table_info */\ } /* converting_tmp_table_to_ondisk */\ },\ {\ "filesort_information": [\ {\ "direction": "desc",\ "table": "intermediate_tmp_table",\ "field": "event_date"\ }\ ] /* filesort_information */,\ "filesort_priority_queue_optimization": {\ "limit": 10,\ "rows_estimate": 862,\ "row_size": 381,\ "memory_available": 262144,\ "chosen": true\ } /* filesort_priority_queue_optimization */,\ "filesort_execution": [\ ] /* filesort_execution */,\ "filesort_summary": {\ "rows": 11,\ "examined_rows": 881390,\ "number_of_tmp_files": 0,\ "sort_buffer_size": 4280,\ "sort_mode": ""\ } /* filesort_summary */\ }\ ] /* steps */\ } /* join_execution */\ }\ ] /* steps */\ } 0 0