|
I think we hit this one almost immediately. Upgraded one replica from 10.3 to 10.5 and had to quickly pull it out of the read pool due to queries taking so long.
This config change isn't documented anywhere on the 10.3 to 10.4 upgrade page. It would be helpful to have this documented there as well as a link to this ticket. I had to dig to find this.
Here is one example query:
SELECT bbs_visitors.user_id, bbs_visitors.forum_id, bbs_visitors.visitdate, users.user_id, users.user_name, users.password, users.first_name, users.last_name, users.last_modified, users.origin, users.email, users.last_pw_send, users.has_profile, users.validated, users.in_fannet, users.locked, users.update_version, users.last_pw_change, users.last_email_confirmation FROM bbs_visitors JOIN users ON bbs_visitors.user_id=users.user_id LEFT JOIN user_options ON user_options.user_id = users.user_id and user_options.option_id = 27 WHERE bbs_visitors.user_id IN ('8791150', '3009427') AND visitdate >= DATE_SUB(NOW(), INTERVAL 20 MINUTE) AND (user_options.user_id IS NULL OR user_options.value = '0')
|
Table definitions:
Create Table: CREATE TABLE `bbs_visitors` (
|
`user_id` int(11) NOT NULL DEFAULT 0,
|
`forum_id` int(11) NOT NULL DEFAULT 0,
|
`visitdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
PRIMARY KEY (`user_id`),
|
KEY `visitdate` (`visitdate`),
|
KEY `forum_id` (`forum_id`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1
|
|
Create Table: CREATE TABLE `user_options` (
|
`option_id` int(11) NOT NULL DEFAULT 0,
|
`user_id` int(11) NOT NULL DEFAULT 0,
|
`value` text DEFAULT NULL,
|
PRIMARY KEY (`option_id`,`user_id`),
|
KEY `user_options_0` (`user_id`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
|
Create Table: CREATE TABLE `users` (
|
`user_id` int(11) NOT NULL AUTO_INCREMENT,
|
`user_name` varchar(20) NOT NULL DEFAULT '',
|
`password` varchar(72) DEFAULT NULL,
|
`first_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`last_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`last_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
`origin` datetime DEFAULT NULL,
|
`email` varchar(50) NOT NULL DEFAULT '',
|
`receive_update` char(1) DEFAULT NULL,
|
`last_pw_send` datetime DEFAULT NULL,
|
`website_url` varchar(60) DEFAULT NULL,
|
`website_title` varchar(30) DEFAULT NULL,
|
`receive_portal_daily` char(1) DEFAULT 'Y',
|
`has_profile` char(1) DEFAULT 'N',
|
`validated` char(1) NOT NULL DEFAULT '',
|
`in_fannet` char(1) DEFAULT 'N',
|
`aimname` varchar(30) NOT NULL DEFAULT '',
|
`webcam_url` varchar(80) DEFAULT NULL,
|
`locked` tinyint(4) NOT NULL DEFAULT 0,
|
`update_version` int(6) DEFAULT NULL,
|
`last_pw_change` datetime NOT NULL,
|
`last_email_confirmation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
PRIMARY KEY (`user_id`),
|
UNIQUE KEY `user_name_2` (`user_name`),
|
KEY `password` (`password`),
|
KEY `email` (`email`),
|
KEY `has_profile` (`has_profile`),
|
KEY `validated` (`validated`),
|
KEY `first_name` (`first_name`),
|
KEY `last_name` (`last_name`),
|
KEY `origin` (`origin`),
|
KEY `update_version` (`update_version`),
|
KEY `last_pw_change` (`last_pw_change`),
|
KEY `last_email_confirmation` (`last_email_confirmation`)
|
) ENGINE=InnoDB AUTO_INCREMENT=9218654 DEFAULT CHARSET=utf8 PACK_KEYS=1
|
Trace:
analyze format=json SELECT bbs_visitors.user_id, bbs_visitors.forum_id, bbs_visitors.visitdate, users.user_id, users.user_name, users.password, users.first_name, users.last_name, users.last_modified, users.origin, users.email, users.last_pw_send, users.has_profile, users.validated, users.in_fannet, users.locked, users.update_version, users.last_pw_change, users.last_email_confirmation FROM bbs_visitors JOIN users ON bbs_visitors.user_id=users.user_id LEFT JOIN user_options ON user_options.user_id = users.user_id and user_options.option_id = 27 WHERE bbs_visitors.user_id IN ('8791150', '3009427') AND visitdate >= DATE_SUB(NOW(), INTERVAL 20 MINUTE) AND (user_options.user_id IS NULL OR user_options.value = '0') {\
|
"steps": [\
|
{\
|
"join_preparation": {\
|
"select_id": 1,\
|
"steps": [\
|
{\
|
"expanded_query": "select bbs_visitors.user_id AS user_id,bbs_visitors.forum_id AS forum_id,bbs_visitors.visitdate AS visitdate,users.user_id AS user_id,users.user_name AS user_name,users.`password` AS `password`,users.first_name AS first_name,users.last_name AS last_name,users.last_modified AS last_modified,users.origin AS origin,users.email AS email,users.last_pw_send AS last_pw_send,users.has_profile AS has_profile,users.validated AS validated,users.in_fannet AS in_fannet,users.locked AS locked,users.update_version AS update_version,users.last_pw_change AS last_pw_change,users.last_email_confirmation AS last_email_confirmation from ((bbs_visitors join users on(bbs_visitors.user_id = users.user_id)) left join user_options on(user_options.user_id = users.user_id and user_options.option_id = 27)) where bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= current_timestamp() - interval 20 minute and (user_options.user_id is null or user_options.`value` = '0')"\
|
}\
|
]\
|
}\
|
},\
|
{\
|
"join_optimization": {\
|
"select_id": 1,\
|
"steps": [\
|
{\
|
"condition_processing": {\
|
"condition": "WHERE",\
|
"original_condition": "bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= current_timestamp() - interval 20 minute and (user_options.user_id is null or user_options.`value` = '0') and bbs_visitors.user_id = users.user_id",\
|
"steps": [\
|
{\
|
"transformation": "equality_propagation",\
|
"resulting_condition": "bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= current_timestamp() - interval 20 minute and (user_options.user_id is null or user_options.`value` = '0') and multiple equal(bbs_visitors.user_id, users.user_id)"\
|
},\
|
{\
|
"transformation": "constant_propagation",\
|
"resulting_condition": "bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= current_timestamp() - interval 20 minute and (user_options.user_id is null or user_options.`value` = '0') and multiple equal(bbs_visitors.user_id, users.user_id)"\
|
},\
|
{\
|
"transformation": "trivial_condition_removal",\
|
"resulting_condition": "bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= current_timestamp() - interval 20 minute and (user_options.user_id is null or user_options.`value` = '0') and multiple equal(bbs_visitors.user_id, users.user_id)"\
|
}\
|
]\
|
}\
|
},\
|
{\
|
"table_dependencies": [\
|
{\
|
"table": "bbs_visitors",\
|
"row_may_be_null": false,\
|
"map_bit": 0,\
|
"depends_on_map_bits": []\
|
},\
|
{\
|
"table": "users",\
|
"row_may_be_null": false,\
|
"map_bit": 1,\
|
"depends_on_map_bits": []\
|
},\
|
{\
|
"table": "user_options",\
|
"row_may_be_null": true,\
|
"map_bit": 2,\
|
"depends_on_map_bits": ["1"]\
|
}\
|
]\
|
},\
|
{\
|
"ref_optimizer_key_uses": [\
|
{\
|
"table": "bbs_visitors",\
|
"field": "user_id",\
|
"equals": "users.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "users",\
|
"field": "user_id",\
|
"equals": "bbs_visitors.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "option_id",\
|
"equals": "27",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "user_id",\
|
"equals": "bbs_visitors.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "user_id",\
|
"equals": "users.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "user_id",\
|
"equals": "bbs_visitors.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "user_id",\
|
"equals": "users.user_id",\
|
"null_rejecting": false\
|
},\
|
{\
|
"table": "user_options",\
|
"field": "option_id",\
|
"equals": "27",\
|
"null_rejecting": false\
|
}\
|
]\
|
},\
|
{\
|
"eliminated_tables": []\
|
},\
|
{\
|
"rows_estimation": [\
|
{\
|
"table": "bbs_visitors",\
|
"range_analysis": {\
|
"table_scan": {\
|
"rows": 255,\
|
"cost": 54\
|
},\
|
"potential_range_indexes": [\
|
{\
|
"index": "PRIMARY",\
|
"usable": true,\
|
"key_parts": ["user_id"]\
|
},\
|
{\
|
"index": "visitdate",\
|
"usable": true,\
|
"key_parts": ["visitdate", "user_id"]\
|
},\
|
{\
|
"index": "forum_id",\
|
"usable": false,\
|
"cause": "not applicable"\
|
}\
|
],\
|
"setup_range_conditions": [],\
|
"analyzing_range_alternatives": {\
|
"range_scan_alternatives": [\
|
{\
|
"index": "PRIMARY",\
|
"ranges": [\
|
"(3009427) <= (user_id) <= (3009427)",\
|
"(8791150) <= (user_id) <= (8791150)"\
|
],\
|
"rowid_ordered": true,\
|
"using_mrr": false,\
|
"index_only": false,\
|
"rows": 2,\
|
"cost": 2.671892148,\
|
"chosen": true\
|
},\
|
{\
|
"index": "visitdate",\
|
"ranges": [\
|
"(2021-05-07 22:43:53,3009427) <= (visitdate,user_id)"\
|
],\
|
"rowid_ordered": false,\
|
"using_mrr": false,\
|
"index_only": false,\
|
"rows": 96,\
|
"cost": 115.3555462,\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"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": "PRIMARY",\
|
"rows": 2,\
|
"ranges": [\
|
"(3009427) <= (user_id) <= (3009427)",\
|
"(8791150) <= (user_id) <= (8791150)"\
|
]\
|
},\
|
"rows_for_plan": 2,\
|
"cost_for_plan": 2.671892148,\
|
"chosen": true\
|
}\
|
}\
|
},\
|
{\
|
"table": "bbs_visitors",\
|
"rowid_filters": [\
|
{\
|
"key": "visitdate",\
|
"build_cost": 4.997320495,\
|
"rows": 96\
|
}\
|
]\
|
},\
|
{\
|
"selectivity_for_indexes": [\
|
{\
|
"index_name": "visitdate",\
|
"selectivity_from_index": 0.376470588\
|
}\
|
],\
|
"selectivity_for_columns": [],\
|
"cond_selectivity": 0.376470588\
|
},\
|
{\
|
"table": "users",\
|
"table_scan": {\
|
"rows": 7613212,\
|
"cost": 93055\
|
}\
|
},\
|
{\
|
"table": "user_options",\
|
"range_analysis": {\
|
"table_scan": {\
|
"rows": 4987025,\
|
"cost": 1012753\
|
},\
|
"potential_range_indexes": [\
|
{\
|
"index": "PRIMARY",\
|
"usable": true,\
|
"key_parts": ["option_id", "user_id"]\
|
},\
|
{\
|
"index": "user_options_0",\
|
"usable": false,\
|
"cause": "not applicable"\
|
}\
|
],\
|
"setup_range_conditions": [],\
|
"analyzing_range_alternatives": {\
|
"range_scan_alternatives": [\
|
{\
|
"index": "PRIMARY",\
|
"ranges": ["(27) <= (option_id) <= (27)"],\
|
"rowid_ordered": true,\
|
"using_mrr": false,\
|
"index_only": false,\
|
"rows": 125260,\
|
"cost": 25176.01597,\
|
"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": "PRIMARY",\
|
"rows": 125260,\
|
"ranges": ["(27) <= (option_id) <= (27)"]\
|
},\
|
"rows_for_plan": 125260,\
|
"cost_for_plan": 25176.01597,\
|
"chosen": true\
|
}\
|
}\
|
},\
|
{\
|
"selectivity_for_indexes": [\
|
{\
|
"index_name": "PRIMARY",\
|
"selectivity_from_index": 0.025117179\
|
}\
|
],\
|
"selectivity_for_columns": [],\
|
"cond_selectivity": 0.025117179\
|
}\
|
]\
|
},\
|
{\
|
"considered_execution_plans": [\
|
{\
|
"plan_prefix": [],\
|
"table": "bbs_visitors",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "range",\
|
"resulting_rows": 96,\
|
"cost": 1.79769e308,\
|
"chosen": true\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "range",\
|
"records": 96,\
|
"cost": 1.79769e308,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 96,\
|
"cost_for_plan": 1.79769e308,\
|
"rest_of_plan": [\
|
{\
|
"plan_prefix": ["bbs_visitors"],\
|
"table": "users",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "eq_ref",\
|
"index": "PRIMARY",\
|
"rows": 1,\
|
"cost": 96,\
|
"chosen": true\
|
},\
|
{\
|
"type": "scan",\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "eq_ref",\
|
"records": 1,\
|
"cost": 96,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 96,\
|
"cost_for_plan": 1.79769e308,\
|
"rest_of_plan": [\
|
{\
|
"plan_prefix": ["bbs_visitors", "users"],\
|
"table": "user_options",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "eq_ref",\
|
"index": "PRIMARY",\
|
"rows": 1,\
|
"cost": 96,\
|
"chosen": true\
|
},\
|
{\
|
"access_type": "eq_ref",\
|
"index": "user_options_0",\
|
"rows": 1,\
|
"cost": 96,\
|
"chosen": false,\
|
"cause": "cost"\
|
},\
|
{\
|
"type": "scan",\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "eq_ref",\
|
"records": 1,\
|
"cost": 96,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 96,\
|
"cost_for_plan": 1.79769e308,\
|
"estimated_join_cardinality": 96\
|
}\
|
]\
|
}\
|
]\
|
},\
|
{\
|
"plan_prefix": [],\
|
"table": "users",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "scan",\
|
"resulting_rows": 7613212,\
|
"cost": 93055,\
|
"chosen": true\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "scan",\
|
"records": 7613212,\
|
"cost": 93055,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 7613212,\
|
"cost_for_plan": 1615697.4,\
|
"rest_of_plan": [\
|
{\
|
"plan_prefix": ["users"],\
|
"table": "bbs_visitors",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "eq_ref",\
|
"index": "PRIMARY",\
|
"rows": 1,\
|
"cost": 7613212,\
|
"chosen": true\
|
},\
|
{\
|
"type": "scan",\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "eq_ref",\
|
"records": 1,\
|
"cost": 7613212,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 7613212,\
|
"cost_for_plan": 10751551.8,\
|
"selectivity": 0.376470588,\
|
"rest_of_plan": [\
|
{\
|
"plan_prefix": ["users", "bbs_visitors"],\
|
"table": "user_options",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "eq_ref",\
|
"index": "PRIMARY",\
|
"rows": 1,\
|
"cost": 2866150.4,\
|
"chosen": true\
|
},\
|
{\
|
"access_type": "eq_ref",\
|
"index": "user_options_0",\
|
"rows": 1,\
|
"cost": 2866150.4,\
|
"chosen": false,\
|
"cause": "cost"\
|
},\
|
{\
|
"type": "scan",\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "eq_ref",\
|
"records": 1,\
|
"cost": 2866150.4,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 2866150.4,\
|
"cost_for_plan": 14190932.28,\
|
"estimated_join_cardinality": 2866150.4\
|
}\
|
]\
|
},\
|
{\
|
"plan_prefix": ["users"],\
|
"table": "user_options",\
|
"best_access_path": {\
|
"considered_access_paths": [\
|
{\
|
"access_type": "eq_ref",\
|
"index": "PRIMARY",\
|
"rows": 1,\
|
"cost": 7613212,\
|
"chosen": true\
|
},\
|
{\
|
"access_type": "eq_ref",\
|
"index": "user_options_0",\
|
"rows": 1,\
|
"cost": 7613212,\
|
"chosen": false,\
|
"cause": "cost"\
|
},\
|
{\
|
"type": "scan",\
|
"chosen": false,\
|
"cause": "cost"\
|
}\
|
],\
|
"chosen_access_method": {\
|
"type": "eq_ref",\
|
"records": 1,\
|
"cost": 7613212,\
|
"uses_join_buffering": false\
|
}\
|
},\
|
"rows_for_plan": 7613212,\
|
"cost_for_plan": 10751551.8,\
|
"pruned_by_heuristic": true\
|
}\
|
]\
|
}\
|
]\
|
},\
|
{\
|
"best_join_order": ["users", "bbs_visitors", "user_options"]\
|
},\
|
{\
|
"attaching_conditions_to_tables": {\
|
"original_condition": "bbs_visitors.user_id = users.user_id and bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= <cache>(current_timestamp() - interval 20 minute) and (user_options.user_id is null or user_options.`value` = '0')",\
|
"attached_conditions_computation": [],\
|
"attached_conditions_summary": [\
|
{\
|
"table": "users",\
|
"attached": null\
|
},\
|
{\
|
"table": "bbs_visitors",\
|
"attached": "bbs_visitors.user_id in ('8791150','3009427') and bbs_visitors.visitdate >= <cache>(current_timestamp() - interval 20 minute)"\
|
},\
|
{\
|
"table": "user_options",\
|
"attached": "trigcond(user_options.user_id is null or user_options.`value` = '0')"\
|
}\
|
]\
|
}\
|
}\
|
]\
|
}\
|
},\
|
{\
|
"join_execution": {\
|
"select_id": 1,\
|
"steps": []\
|
}\
|
}\
|
]\
|
} 0 0
|
Luckily setting optimizer_use_condition_selectivity back to 1 immediately fixed this.
|