{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/72210044","id":72210044,"diff_hunk":"@@ -0,0 +1,196 @@\n+// Copyright 2016 PingCAP, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package plan\n+\n+import (\n+\t\"github.com/pingcap/tidb/util/types\"\n+\t\"math\"\n+)\n+\n+// matchProperty implements PhysicalPlan matchProperty interface.\n+func (ts *PhysicalTableScan) matchProperty(prop requiredProperty, rowCounts []uint64, _ ...*physicalPlanInfo) *physicalPlanInfo {\n+\trowCount := float64(rowCounts[0])\n+\tcost := rowCount * netWorkFactor\n+\tif len(prop) == 0 {\n+\t\treturn &physicalPlanInfo{p: ts, cost: cost}\n+\t}\n+\tif len(prop) == 1 && ts.pkCol != nil && ts.pkCol == prop[0].col {\n+\t\tsortedTs := *ts\n+\t\tsortedTs.Desc = prop[0].desc\n+\t\treturn &physicalPlanInfo{p: &sortedTs, cost: cost}\n+\t}\n+\treturn &physicalPlanInfo{p: ts, cost: math.MaxFloat64}\n+}\n+\n+// matchProperty implements PhysicalPlan matchProperty interface.\n+func (is *PhysicalIndexScan) matchProperty(prop requiredProperty, rowCounts []uint64, _ ...*physicalPlanInfo) *physicalPlanInfo {\n+\trowCount := float64(rowCounts[0])\n+\t// currently index read from kv 2 times.\n+\tcost := rowCount * netWorkFactor * 2\n+\tif len(prop) == 0 {\n+\t\treturn &physicalPlanInfo{p: is, cost: cost}\n+\t}\n+\tmatched := 0\n+\tallDesc, allAsc := true, true\n+\tfor i, indexCol := range is.Index.Columns {\n+\t\tif indexCol.Length != types.UnspecifiedLength {\n+\t\t\tbreak\n+\t\t}\n+\t\tif prop[matched].col.ColName.L != indexCol.Name.L {\n+\t\t\tif matched != 0 || i >= is.accessEqualCount {\n+\t\t\t\tbreak\n+\t\t\t}\n+\t\t\tcontinue\n+\t\t}\n+\t\tif prop[matched].desc {\n+\t\t\tallAsc = false\n+\t\t} else {\n+\t\t\tallDesc = false\n+\t\t}\n+\t\tmatched++\n+\t\tif matched == len(prop) {\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\tif matched == len(prop) {\n+\t\tsortedCost := cost + rowCount*math.Log2(rowCount)","path":"plan/match_property.go","position":67,"original_position":67,"commit_id":"0480a0021fd7a75e4714f7a43f771b83a68d831d","original_commit_id":"0480a0021fd7a75e4714f7a43f771b83a68d831d","user":{"login":"coocood","id":891222,"avatar_url":"https://avatars.githubusercontent.com/u/891222?v=3","gravatar_id":"","url":"https://api.github.com/users/coocood","html_url":"https://github.com/coocood","followers_url":"https://api.github.com/users/coocood/followers","following_url":"https://api.github.com/users/coocood/following{/other_user}","gists_url":"https://api.github.com/users/coocood/gists{/gist_id}","starred_url":"https://api.github.com/users/coocood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coocood/subscriptions","organizations_url":"https://api.github.com/users/coocood/orgs","repos_url":"https://api.github.com/users/coocood/repos","events_url":"https://api.github.com/users/coocood/events{/privacy}","received_events_url":"https://api.github.com/users/coocood/received_events","type":"User","site_admin":false},"body":"Multiply CPUFactor","created_at":"2016-07-26T08:46:21Z","updated_at":"2016-07-26T08:46:21Z","html_url":"https://github.com/pingcap/tidb/pull/1498#discussion_r72210044","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/1498","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/72210044"},"html":{"href":"https://github.com/pingcap/tidb/pull/1498#discussion_r72210044"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/1498"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/1498","id":78626835,"html_url":"https://github.com/pingcap/tidb/pull/1498","diff_url":"https://github.com/pingcap/tidb/pull/1498.diff","patch_url":"https://github.com/pingcap/tidb/pull/1498.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/1498","number":1498,"state":"open","locked":false,"title":"[DNM]support cbo","user":{"login":"hanfei19910905","id":4242394,"avatar_url":"https://avatars.githubusercontent.com/u/4242394?v=3","gravatar_id":"","url":"https://api.github.com/users/hanfei19910905","html_url":"https://github.com/hanfei19910905","followers_url":"https://api.github.com/users/hanfei19910905/followers","following_url":"https://api.github.com/users/hanfei19910905/following{/other_user}","gists_url":"https://api.github.com/users/hanfei19910905/gists{/gist_id}","starred_url":"https://api.github.com/users/hanfei19910905/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanfei19910905/subscriptions","organizations_url":"https://api.github.com/users/hanfei19910905/orgs","repos_url":"https://api.github.com/users/hanfei19910905/repos","events_url":"https://api.github.com/users/hanfei19910905/events{/privacy}","received_events_url":"https://api.github.com/users/hanfei19910905/received_events","type":"User","site_admin":false},"body":"@shenli @zimulala @coocood @tiancaiamao PTAL","created_at":"2016-07-25T05:06:29Z","updated_at":"2016-07-26T08:46:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"085693848fe903a4f74af267769d10559807d8f8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/1498/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/1498/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/1498/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/0480a0021fd7a75e4714f7a43f771b83a68d831d","head":{"label":"pingcap:hanfei/cbo","ref":"hanfei/cbo","sha":"0480a0021fd7a75e4714f7a43f771b83a68d831d","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","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,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","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},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed NewSQL database compatible with 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":"2016-07-26T08:37:06Z","pushed_at":"2016-07-26T08:23:18Z","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":"","size":21751,"stargazers_count":4348,"watchers_count":4348,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":547,"mirror_url":null,"open_issues_count":103,"forks":547,"open_issues":103,"watchers":4348,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"04da3d2f8b02bcb2b8184f6e25063cd9bd92e8e4","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","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,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","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},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed NewSQL database compatible with 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":"2016-07-26T08:37:06Z","pushed_at":"2016-07-26T08:23:18Z","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":"","size":21751,"stargazers_count":4348,"watchers_count":4348,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":547,"mirror_url":null,"open_issues_count":103,"forks":547,"open_issues":103,"watchers":4348,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/1498"},"html":{"href":"https://github.com/pingcap/tidb/pull/1498"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/1498"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/1498/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/1498/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/1498/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/0480a0021fd7a75e4714f7a43f771b83a68d831d"}}}}
{"actor":{"display_login":"coocood"}}