{"action":"created","issue":{"url":"https://api.github.com/repos/pingcap/tidb/issues/8286","repository_url":"https://api.github.com/repos/pingcap/tidb","labels_url":"https://api.github.com/repos/pingcap/tidb/issues/8286/labels{/name}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/8286/comments","events_url":"https://api.github.com/repos/pingcap/tidb/issues/8286/events","html_url":"https://github.com/pingcap/tidb/issues/8286","id":379843588,"node_id":"MDU6SXNzdWUzNzk4NDM1ODg=","number":8286,"title":"Explain shows very large count statistic for an index scan","user":{"login":"lerencao","id":1456096,"node_id":"MDQ6VXNlcjE0NTYwOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1456096?v=4","gravatar_id":"","url":"https://api.github.com/users/lerencao","html_url":"https://github.com/lerencao","followers_url":"https://api.github.com/users/lerencao/followers","following_url":"https://api.github.com/users/lerencao/following{/other_user}","gists_url":"https://api.github.com/users/lerencao/gists{/gist_id}","starred_url":"https://api.github.com/users/lerencao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lerencao/subscriptions","organizations_url":"https://api.github.com/users/lerencao/orgs","repos_url":"https://api.github.com/users/lerencao/repos","events_url":"https://api.github.com/users/lerencao/events{/privacy}","received_events_url":"https://api.github.com/users/lerencao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-12T16:03:37Z","updated_at":"2018-11-12T23:34:39Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Bug Report\r\n\r\nPlease answer these questions before submitting your issue. Thanks!\r\n\r\n1. What did you do?\r\nIf possible, provide a recipe for reproducing the error.\r\n\r\nWe have a table which has about 90m rows of data. and the table has an index which contains only a single column named `company_name`.\r\n\r\n``` sql\r\nCREATE TABLE `tt` (\r\n  `uid` bigint(20) UNSIGNED NOT NULL,\r\n  `tid` varchar(50) NOT NULL COMMENT,\r\n  `email` varchar(50) DEFAULT NULL,\r\n  `idno` varchar(20) DEFAULT NULL,\r\n  `realname` varchar(20) DEFAULT NULL,\r\n  `bind_mob` varchar(20) DEFAULT NULL,\r\n  `main_contact_name` varchar(50) DEFAULT NULL,\r\n  `main_contact_rela` varchar(50) DEFAULT NULL,\r\n  `main_contact_tel` varchar(50) DEFAULT NULL,\r\n  `main_contact_name2` varchar(50) DEFAULT NULL,\r\n  `main_contact_rela2` varchar(50) DEFAULT NULL,\r\n  `main_contact_tel2` varchar(50) DEFAULT NULL,\r\n  `address_prov` varchar(50) DEFAULT NULL,\r\n  `address_city` varchar(50) DEFAULT NULL,\r\n  `address_county` varchar(50) DEFAULT NULL,\r\n  `address_detail` varchar(100) DEFAULT NULL,\r\n  `salary_range` varchar(20) DEFAULT NULL,\r\n  `work_years` varchar(20) DEFAULT NULL,\r\n  `education` varchar(20) DEFAULT NULL,\r\n  `company_name` varchar(50) DEFAULT NULL,\r\n  `marriage` varchar(20) DEFAULT NULL,\r\n  `job_type` varchar(20) DEFAULT NULL,\r\n  `ext_data` text DEFAULT NULL,\r\n  `flow` varchar(20) NOT NULL,\r\n  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n  `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n  `binlog_time` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'ts',\r\n  PRIMARY KEY (`uid`,`tid`,`flow`),\r\n  KEY `idx_idno` (`idno`),\r\n  KEY `idx_tid` (`tid`),\r\n  KEY `idx_bind_mob` (`bind_mob`),\r\n  KEY `idx_main_contact_tel` (`main_contact_tel`),\r\n  KEY `idx_email` (`email`),\r\n  KEY `idx_company_name` (`company_name`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;\r\n\r\n```\r\nWe have a query pattern: `select * from tt where company_name = #{xxx}`. It works online for a few months.\r\nHowever, last week I received an alert that the following query wasn't using index scan. In fact, this sql returns one row only.\r\n\r\n``` sql\r\nselect * from tt where company_name = '余京筋骨体验堂';\r\n```\r\nInterestingly,  `select * from tt where company_name = '余京筋骨体验'` works expectedly. \r\nSee the picture below.\r\n\r\n\r\n![53381541840850_ pic_hd](https://user-images.githubusercontent.com/1456096/48358819-86937280-e6d6-11e8-9a46-8fa98bbd1de7.jpg)\r\n\r\n\r\n2. What did you expect to see?\r\n\r\nI expected that the sql mentioned should use index scan, instead of full table scan.\r\n\r\n3. What did you see instead?\r\n\r\n\r\n\r\n4. What version of TiDB are you using (`tidb-server -V` or run `select tidb_version();` on TiDB)?\r\n\r\nv2.0.6"},"comment":{"url":"https://api.github.com/repos/pingcap/tidb/issues/comments/438070272","html_url":"https://github.com/pingcap/tidb/issues/8286#issuecomment-438070272","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/8286","id":438070272,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODA3MDI3Mg==","user":{"login":"shenli","id":1192573,"node_id":"MDQ6VXNlcjExOTI1NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1192573?v=4","gravatar_id":"","url":"https://api.github.com/users/shenli","html_url":"https://github.com/shenli","followers_url":"https://api.github.com/users/shenli/followers","following_url":"https://api.github.com/users/shenli/following{/other_user}","gists_url":"https://api.github.com/users/shenli/gists{/gist_id}","starred_url":"https://api.github.com/users/shenli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shenli/subscriptions","organizations_url":"https://api.github.com/users/shenli/orgs","repos_url":"https://api.github.com/users/shenli/repos","events_url":"https://api.github.com/users/shenli/events{/privacy}","received_events_url":"https://api.github.com/users/shenli/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T23:34:39Z","updated_at":"2018-11-12T23:34:39Z","author_association":"MEMBER","body":"@astaxie PTAL"}}
{"actor":{"display_login":"shenli"}}