{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/257614803","pull_request_review_id":204689446,"id":257614803,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1NzYxNDgwMw==","diff_hunk":"@@ -196,6 +197,135 @@ func (ds *DataSource) tryToGetDualTask() (task, error) {\n \treturn nil, nil\n }\n \n+// candidatePath is used to maintain required info for skyline pruning.\n+type candidatePath struct {\n+\tpath         *accessPath\n+\tcolumnSet    *intsets.Sparse // columnSet is the set of columns that occurred in the access conditions.\n+\tisSingleScan bool\n+\tisMatchProp  bool\n+}\n+\n+// compareColumnSet will compares the two set. The last return value is used to indicate\n+// if they are comparable, it is false when both two sets have columns that do not occur in the other.\n+// When the second return value is true, the value of first:\n+// (1) -1 means that `l` is a strict subset of `r`;\n+// (2) 0 means that `l` equals to `r`;\n+// (3) 1 means that `l` is a strict superset of `r`.\n+func compareColumnSet(l, r *intsets.Sparse) (int, bool) {\n+\tlLen, rLen := l.Len(), r.Len()\n+\tif lLen <= rLen {\n+\t\tif isSubset := l.SubsetOf(r); !isSubset {\n+\t\t\treturn 0, false\n+\t\t}\n+\t\tif lLen == rLen {\n+\t\t\treturn 0, true\n+\t\t}\n+\t\treturn -1, true\n+\t}\n+\tif isSubset := r.SubsetOf(l); !isSubset {\n+\t\treturn 0, false\n+\t}\n+\treturn 1, true\n+}\n+\n+func compareBool(l, r bool) int {\n+\tif l == r {\n+\t\treturn 0\n+\t}\n+\tif l == false {\n+\t\treturn -1\n+\t}\n+\treturn 1\n+}\n+\n+// compareCandidates is the core of skyline pruning. It compares the two candidate paths on three dimensions:\n+// (1): the set of columns that occurred in the access condition,\n+// (2): whether or not it matches the physical property\n+// (3): does it require a double scan.\n+// If `x` is not worse than `y` at all factors,\n+// and there exists one factor that `x` is better than `y`, then `x` is better than `y`.\n+func compareCandidates(lhs, rhs *candidatePath) int {\n+\tsetsResult, comparable := compareColumnSet(lhs.columnSet, rhs.columnSet)\n+\tif !comparable {\n+\t\treturn 0\n+\t}\n+\tscanResult := compareBool(lhs.isSingleScan, rhs.isSingleScan)\n+\tmatchResult := compareBool(lhs.isMatchProp, rhs.isMatchProp)\n+\tsum := setsResult + scanResult + matchResult\n+\tif setsResult >= 0 && scanResult >= 0 && matchResult >= 0 && sum > 0 {","path":"planner/core/find_best_task.go","position":67,"original_position":67,"commit_id":"a58086fb0eb49b8d8552096b708bac4238c11f1d","original_commit_id":"fd27eb321e3ea60aae1f362f53a2db26e9af3034","user":{"login":"zz-jason","id":5268763,"node_id":"MDQ6VXNlcjUyNjg3NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/5268763?v=4","gravatar_id":"","url":"https://api.github.com/users/zz-jason","html_url":"https://github.com/zz-jason","followers_url":"https://api.github.com/users/zz-jason/followers","following_url":"https://api.github.com/users/zz-jason/following{/other_user}","gists_url":"https://api.github.com/users/zz-jason/gists{/gist_id}","starred_url":"https://api.github.com/users/zz-jason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz-jason/subscriptions","organizations_url":"https://api.github.com/users/zz-jason/orgs","repos_url":"https://api.github.com/users/zz-jason/repos","events_url":"https://api.github.com/users/zz-jason/events{/privacy}","received_events_url":"https://api.github.com/users/zz-jason/received_events","type":"User","site_admin":false},"body":"never mind ...","created_at":"2019-02-18T09:29:38Z","updated_at":"2019-02-18T09:29:38Z","html_url":"https://github.com/pingcap/tidb/pull/9337#discussion_r257614803","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/9337","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/257614803"},"html":{"href":"https://github.com/pingcap/tidb/pull/9337#discussion_r257614803"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/9337"}},"in_reply_to_id":257604706},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/9337","id":253771873,"node_id":"MDExOlB1bGxSZXF1ZXN0MjUzNzcxODcz","html_url":"https://github.com/pingcap/tidb/pull/9337","diff_url":"https://github.com/pingcap/tidb/pull/9337.diff","patch_url":"https://github.com/pingcap/tidb/pull/9337.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/9337","number":9337,"state":"open","locked":false,"title":" planner/core: implement skyline pruning","user":{"login":"lamxTyler","id":16222711,"node_id":"MDQ6VXNlcjE2MjIyNzEx","avatar_url":"https://avatars1.githubusercontent.com/u/16222711?v=4","gravatar_id":"","url":"https://api.github.com/users/lamxTyler","html_url":"https://github.com/lamxTyler","followers_url":"https://api.github.com/users/lamxTyler/followers","following_url":"https://api.github.com/users/lamxTyler/following{/other_user}","gists_url":"https://api.github.com/users/lamxTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/lamxTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamxTyler/subscriptions","organizations_url":"https://api.github.com/users/lamxTyler/orgs","repos_url":"https://api.github.com/users/lamxTyler/repos","events_url":"https://api.github.com/users/lamxTyler/events{/privacy}","received_events_url":"https://api.github.com/users/lamxTyler/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for contributing to TiDB! Please read TiDB's [CONTRIBUTING](https://github.com/pingcap/tidb/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add issue link with summary if exists-->\r\n\r\nFix https://github.com/pingcap/tidb/issues/8593\r\n\r\n### What is changed and how it works?\r\n\r\nImplement the skyline pruning according to the [proposal]( https://github.com/pingcap/tidb/blob/master/docs/design/2019-01-25-skyline-pruning.md).\r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n - Unit test\r\n\r\nCode changes\r\n\r\n - Has exported function/method change\r\n\r\nSide effects\r\n\r\n - None\r\n\r\nRelated changes\r\n\r\n - Need to cherry-pick to the release branch\r\n","created_at":"2019-02-18T03:23:45Z","updated_at":"2019-02-18T09:29:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af2e5e935b652171316c39f73005e52aab4ebe12","assignee":null,"assignees":[],"requested_reviewers":[{"login":"eurekaka","id":6261973,"node_id":"MDQ6VXNlcjYyNjE5NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/6261973?v=4","gravatar_id":"","url":"https://api.github.com/users/eurekaka","html_url":"https://github.com/eurekaka","followers_url":"https://api.github.com/users/eurekaka/followers","following_url":"https://api.github.com/users/eurekaka/following{/other_user}","gists_url":"https://api.github.com/users/eurekaka/gists{/gist_id}","starred_url":"https://api.github.com/users/eurekaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eurekaka/subscriptions","organizations_url":"https://api.github.com/users/eurekaka/orgs","repos_url":"https://api.github.com/users/eurekaka/repos","events_url":"https://api.github.com/users/eurekaka/events{/privacy}","received_events_url":"https://api.github.com/users/eurekaka/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":667671533,"node_id":"MDU6TGFiZWw2Njc2NzE1MzM=","url":"https://api.github.com/repos/pingcap/tidb/labels/component/planner","name":"component/planner","color":"1d76db","default":false},{"id":256872088,"node_id":"MDU6TGFiZWwyNTY4NzIwODg=","url":"https://api.github.com/repos/pingcap/tidb/labels/type/enhancement","name":"type/enhancement","color":"84b6eb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/9337/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/9337/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/9337/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/a58086fb0eb49b8d8552096b708bac4238c11f1d","head":{"label":"lamxTyler:skyline","ref":"skyline","sha":"a58086fb0eb49b8d8552096b708bac4238c11f1d","user":{"login":"lamxTyler","id":16222711,"node_id":"MDQ6VXNlcjE2MjIyNzEx","avatar_url":"https://avatars1.githubusercontent.com/u/16222711?v=4","gravatar_id":"","url":"https://api.github.com/users/lamxTyler","html_url":"https://github.com/lamxTyler","followers_url":"https://api.github.com/users/lamxTyler/followers","following_url":"https://api.github.com/users/lamxTyler/following{/other_user}","gists_url":"https://api.github.com/users/lamxTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/lamxTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamxTyler/subscriptions","organizations_url":"https://api.github.com/users/lamxTyler/orgs","repos_url":"https://api.github.com/users/lamxTyler/repos","events_url":"https://api.github.com/users/lamxTyler/events{/privacy}","received_events_url":"https://api.github.com/users/lamxTyler/received_events","type":"User","site_admin":false},"repo":{"id":107388999,"node_id":"MDEwOlJlcG9zaXRvcnkxMDczODg5OTk=","name":"tidb","full_name":"lamxTyler/tidb","private":false,"owner":{"login":"lamxTyler","id":16222711,"node_id":"MDQ6VXNlcjE2MjIyNzEx","avatar_url":"https://avatars1.githubusercontent.com/u/16222711?v=4","gravatar_id":"","url":"https://api.github.com/users/lamxTyler","html_url":"https://github.com/lamxTyler","followers_url":"https://api.github.com/users/lamxTyler/followers","following_url":"https://api.github.com/users/lamxTyler/following{/other_user}","gists_url":"https://api.github.com/users/lamxTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/lamxTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamxTyler/subscriptions","organizations_url":"https://api.github.com/users/lamxTyler/orgs","repos_url":"https://api.github.com/users/lamxTyler/repos","events_url":"https://api.github.com/users/lamxTyler/events{/privacy}","received_events_url":"https://api.github.com/users/lamxTyler/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lamxTyler/tidb","description":"TiDB is a distributed NewSQL database compatible with MySQL protocol ","fork":true,"url":"https://api.github.com/repos/lamxTyler/tidb","forks_url":"https://api.github.com/repos/lamxTyler/tidb/forks","keys_url":"https://api.github.com/repos/lamxTyler/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lamxTyler/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lamxTyler/tidb/teams","hooks_url":"https://api.github.com/repos/lamxTyler/tidb/hooks","issue_events_url":"https://api.github.com/repos/lamxTyler/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/lamxTyler/tidb/events","assignees_url":"https://api.github.com/repos/lamxTyler/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/lamxTyler/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/lamxTyler/tidb/tags","blobs_url":"https://api.github.com/repos/lamxTyler/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lamxTyler/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lamxTyler/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/lamxTyler/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lamxTyler/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/lamxTyler/tidb/languages","stargazers_url":"https://api.github.com/repos/lamxTyler/tidb/stargazers","contributors_url":"https://api.github.com/repos/lamxTyler/tidb/contributors","subscribers_url":"https://api.github.com/repos/lamxTyler/tidb/subscribers","subscription_url":"https://api.github.com/repos/lamxTyler/tidb/subscription","commits_url":"https://api.github.com/repos/lamxTyler/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/lamxTyler/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/lamxTyler/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/lamxTyler/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/lamxTyler/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/lamxTyler/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lamxTyler/tidb/merges","archive_url":"https://api.github.com/repos/lamxTyler/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lamxTyler/tidb/downloads","issues_url":"https://api.github.com/repos/lamxTyler/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/lamxTyler/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/lamxTyler/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/lamxTyler/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lamxTyler/tidb/labels{/name}","releases_url":"https://api.github.com/repos/lamxTyler/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/lamxTyler/tidb/deployments","created_at":"2017-10-18T09:49:38Z","updated_at":"2019-01-15T09:36:22Z","pushed_at":"2019-02-18T09:22:41Z","git_url":"git://github.com/lamxTyler/tidb.git","ssh_url":"git@github.com:lamxTyler/tidb.git","clone_url":"https://github.com/lamxTyler/tidb.git","svn_url":"https://github.com/lamxTyler/tidb","homepage":"https://pingcap.com","size":70363,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"cc085693f10ee4a840a36d3b371de62a4f660044","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"node_id":"MDEwOlJlcG9zaXRvcnk0MTk4NjM2OQ==","name":"tidb","full_name":"pingcap/tidb","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb/deployments","created_at":"2015-09-06T04:01:52Z","updated_at":"2019-02-18T09:14:53Z","pushed_at":"2019-02-18T09:29:35Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"https://pingcap.com","size":127694,"stargazers_count":17341,"watchers_count":17341,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2484,"mirror_url":null,"archived":false,"open_issues_count":725,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2484,"open_issues":725,"watchers":17341,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/9337"},"html":{"href":"https://github.com/pingcap/tidb/pull/9337"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/9337"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/9337/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/9337/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/9337/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/a58086fb0eb49b8d8552096b708bac4238c11f1d"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"zz-jason"}}