{"action":"created","comment":{"url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/comments/55511480","id":55511480,"diff_hunk":"@@ -777,25 +777,57 @@ read_siblings(User, Channel, [Key | Keys]) ->\n     read_shallow(User, Channel, [lists:reverse(ParentKeyRev)])\n     ++ read_siblings(User, Channel, Keys).\n \n-read_shallow(_User, _Channel, []) -> [];\n-read_shallow(User, Channel, [Key | Keys]) ->\n+read_shallow(User, Channel, Keys) ->\n+    ReadShallowFun = fun() ->\n+        read_shallow_internal(User, Channel, Keys)\n+    end,\n+    imem_meta:return_atomic(imem_meta:transaction(ReadShallowFun)).\n+\n+read_shallow_internal(_User, _Channel, []) -> [];\n+read_shallow_internal(User, Channel, [Key | Keys]) ->\n     KeyLen = length(binterm_to_term_key(Key)) + 1,\n-    [SkvhRow || #{ckey := CK} = SkvhRow <- read_deep(User, Channel, [Key]),\n-                length(CK) == KeyLen]\n-    ++ read_shallow(User, Channel, Keys).\n+    StartKey = term_key_to_binterm(Key),\n+    EndKey = term_key_to_binterm(binterm_to_term_key(Key) ++ <<255>>),\n+    TableName = atom_table_name(Channel),\n+    read_shallow_single(Channel, TableName, StartKey, EndKey, KeyLen) ++ \n+        read_shallow_internal(User, Channel, Keys).","path":"src/imem_dal_skvh.erl","position":22,"original_position":22,"commit_id":"1c757cdc8e17281b43230c393bef97307b28bfac","original_commit_id":"1c757cdc8e17281b43230c393bef97307b28bfac","user":{"login":"c-bik","id":913008,"avatar_url":"https://avatars.githubusercontent.com/u/913008?v=3","gravatar_id":"","url":"https://api.github.com/users/c-bik","html_url":"https://github.com/c-bik","followers_url":"https://api.github.com/users/c-bik/followers","following_url":"https://api.github.com/users/c-bik/following{/other_user}","gists_url":"https://api.github.com/users/c-bik/gists{/gist_id}","starred_url":"https://api.github.com/users/c-bik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-bik/subscriptions","organizations_url":"https://api.github.com/users/c-bik/orgs","repos_url":"https://api.github.com/users/c-bik/repos","events_url":"https://api.github.com/users/c-bik/events{/privacy}","received_events_url":"https://api.github.com/users/c-bik/received_events","type":"User","site_admin":false},"body":"Can you tail recurse in this case?","created_at":"2016-03-09T12:33:08Z","updated_at":"2016-03-09T12:33:08Z","html_url":"https://github.com/K2InformaticsGmbH/imem/pull/76#discussion_r55511480","pull_request_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/comments/55511480"},"html":{"href":"https://github.com/K2InformaticsGmbH/imem/pull/76#discussion_r55511480"},"pull_request":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76","id":62212398,"html_url":"https://github.com/K2InformaticsGmbH/imem/pull/76","diff_url":"https://github.com/K2InformaticsGmbH/imem/pull/76.diff","patch_url":"https://github.com/K2InformaticsGmbH/imem/pull/76.patch","issue_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/76","number":76,"state":"open","locked":false,"title":"read deep / shallow speedup","user":{"login":"acautin","id":949102,"avatar_url":"https://avatars.githubusercontent.com/u/949102?v=3","gravatar_id":"","url":"https://api.github.com/users/acautin","html_url":"https://github.com/acautin","followers_url":"https://api.github.com/users/acautin/followers","following_url":"https://api.github.com/users/acautin/following{/other_user}","gists_url":"https://api.github.com/users/acautin/gists{/gist_id}","starred_url":"https://api.github.com/users/acautin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acautin/subscriptions","organizations_url":"https://api.github.com/users/acautin/orgs","repos_url":"https://api.github.com/users/acautin/repos","events_url":"https://api.github.com/users/acautin/events{/privacy}","received_events_url":"https://api.github.com/users/acautin/received_events","type":"User","site_admin":false},"body":"Directly reading using imem_meta:next instead of using select, as it is faster.\r\nFilter for shallow read without having to construct the maps for discarded results.\r\n\r\n```\r\n09:28:39.450 [info] [_SBS_] {sbs_dal,409} time read shallow count: 899, average: 34219.228031145714, total: 30.763086 (Seconds)\r\n11:26:45.688 [info] [_SBS_] {sbs_dal,409} time read shallow count: 899, average: 205.2258064516129, total: 0.184498 (Seconds)\r\n```\r\n\r\n```\r\n11:43:06.624 [info] [_SBS_] {sbs_dal,685} time read deep count: 899, average: 33930.34149054505, total: 30.503377 (Seconds)\r\n11:59:41.704 [info] [_SBS_] {sbs_dal,685} time read deep count: 899, average: 4719.806451612903, total: 4.243106 (Seconds)\r\n```","created_at":"2016-03-09T11:07:31Z","updated_at":"2016-03-09T12:33:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a611bbeb93e20a468fd501cc65ed6e65cce3a20","assignee":{"login":"c-bik","id":913008,"avatar_url":"https://avatars.githubusercontent.com/u/913008?v=3","gravatar_id":"","url":"https://api.github.com/users/c-bik","html_url":"https://github.com/c-bik","followers_url":"https://api.github.com/users/c-bik/followers","following_url":"https://api.github.com/users/c-bik/following{/other_user}","gists_url":"https://api.github.com/users/c-bik/gists{/gist_id}","starred_url":"https://api.github.com/users/c-bik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-bik/subscriptions","organizations_url":"https://api.github.com/users/c-bik/orgs","repos_url":"https://api.github.com/users/c-bik/repos","events_url":"https://api.github.com/users/c-bik/events{/privacy}","received_events_url":"https://api.github.com/users/c-bik/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76/commits","review_comments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76/comments","review_comment_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/comments{/number}","comments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/76/comments","statuses_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/statuses/1c757cdc8e17281b43230c393bef97307b28bfac","head":{"label":"K2InformaticsGmbH:read_deep_and_shallow_speed_up","ref":"read_deep_and_shallow_speed_up","sha":"1c757cdc8e17281b43230c393bef97307b28bfac","user":{"login":"K2InformaticsGmbH","id":7457120,"avatar_url":"https://avatars.githubusercontent.com/u/7457120?v=3","gravatar_id":"","url":"https://api.github.com/users/K2InformaticsGmbH","html_url":"https://github.com/K2InformaticsGmbH","followers_url":"https://api.github.com/users/K2InformaticsGmbH/followers","following_url":"https://api.github.com/users/K2InformaticsGmbH/following{/other_user}","gists_url":"https://api.github.com/users/K2InformaticsGmbH/gists{/gist_id}","starred_url":"https://api.github.com/users/K2InformaticsGmbH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2InformaticsGmbH/subscriptions","organizations_url":"https://api.github.com/users/K2InformaticsGmbH/orgs","repos_url":"https://api.github.com/users/K2InformaticsGmbH/repos","events_url":"https://api.github.com/users/K2InformaticsGmbH/events{/privacy}","received_events_url":"https://api.github.com/users/K2InformaticsGmbH/received_events","type":"Organization","site_admin":false},"repo":{"id":2635355,"name":"imem","full_name":"K2InformaticsGmbH/imem","owner":{"login":"K2InformaticsGmbH","id":7457120,"avatar_url":"https://avatars.githubusercontent.com/u/7457120?v=3","gravatar_id":"","url":"https://api.github.com/users/K2InformaticsGmbH","html_url":"https://github.com/K2InformaticsGmbH","followers_url":"https://api.github.com/users/K2InformaticsGmbH/followers","following_url":"https://api.github.com/users/K2InformaticsGmbH/following{/other_user}","gists_url":"https://api.github.com/users/K2InformaticsGmbH/gists{/gist_id}","starred_url":"https://api.github.com/users/K2InformaticsGmbH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2InformaticsGmbH/subscriptions","organizations_url":"https://api.github.com/users/K2InformaticsGmbH/orgs","repos_url":"https://api.github.com/users/K2InformaticsGmbH/repos","events_url":"https://api.github.com/users/K2InformaticsGmbH/events{/privacy}","received_events_url":"https://api.github.com/users/K2InformaticsGmbH/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/K2InformaticsGmbH/imem","description":"Clustered in-memory database based on MNESIA with simple SQL layer","fork":false,"url":"https://api.github.com/repos/K2InformaticsGmbH/imem","forks_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/forks","keys_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/teams","hooks_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/hooks","issue_events_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/events{/number}","events_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/events","assignees_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/assignees{/user}","branches_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/branches{/branch}","tags_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/tags","blobs_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/refs{/sha}","trees_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/statuses/{sha}","languages_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/languages","stargazers_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/stargazers","contributors_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/contributors","subscribers_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/subscribers","subscription_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/subscription","commits_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/commits{/sha}","git_commits_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/commits{/sha}","comments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/comments{/number}","issue_comment_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/comments{/number}","contents_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/contents/{+path}","compare_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/merges","archive_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/downloads","issues_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues{/number}","pulls_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls{/number}","milestones_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/milestones{/number}","notifications_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/labels{/name}","releases_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/releases{/id}","deployments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/deployments","created_at":"2011-10-24T10:04:39Z","updated_at":"2016-01-01T10:11:45Z","pushed_at":"2016-03-09T11:07:32Z","git_url":"git://github.com/K2InformaticsGmbH/imem.git","ssh_url":"git@github.com:K2InformaticsGmbH/imem.git","clone_url":"https://github.com/K2InformaticsGmbH/imem.git","svn_url":"https://github.com/K2InformaticsGmbH/imem","homepage":"http://www.k2informatics.ch/","size":2305,"stargazers_count":2,"watchers_count":2,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":21,"forks":2,"open_issues":21,"watchers":2,"default_branch":"master"}},"base":{"label":"K2InformaticsGmbH:master","ref":"master","sha":"3065ad85989a15f13eddcb25c82dc4bc09bd08e4","user":{"login":"K2InformaticsGmbH","id":7457120,"avatar_url":"https://avatars.githubusercontent.com/u/7457120?v=3","gravatar_id":"","url":"https://api.github.com/users/K2InformaticsGmbH","html_url":"https://github.com/K2InformaticsGmbH","followers_url":"https://api.github.com/users/K2InformaticsGmbH/followers","following_url":"https://api.github.com/users/K2InformaticsGmbH/following{/other_user}","gists_url":"https://api.github.com/users/K2InformaticsGmbH/gists{/gist_id}","starred_url":"https://api.github.com/users/K2InformaticsGmbH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2InformaticsGmbH/subscriptions","organizations_url":"https://api.github.com/users/K2InformaticsGmbH/orgs","repos_url":"https://api.github.com/users/K2InformaticsGmbH/repos","events_url":"https://api.github.com/users/K2InformaticsGmbH/events{/privacy}","received_events_url":"https://api.github.com/users/K2InformaticsGmbH/received_events","type":"Organization","site_admin":false},"repo":{"id":2635355,"name":"imem","full_name":"K2InformaticsGmbH/imem","owner":{"login":"K2InformaticsGmbH","id":7457120,"avatar_url":"https://avatars.githubusercontent.com/u/7457120?v=3","gravatar_id":"","url":"https://api.github.com/users/K2InformaticsGmbH","html_url":"https://github.com/K2InformaticsGmbH","followers_url":"https://api.github.com/users/K2InformaticsGmbH/followers","following_url":"https://api.github.com/users/K2InformaticsGmbH/following{/other_user}","gists_url":"https://api.github.com/users/K2InformaticsGmbH/gists{/gist_id}","starred_url":"https://api.github.com/users/K2InformaticsGmbH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/K2InformaticsGmbH/subscriptions","organizations_url":"https://api.github.com/users/K2InformaticsGmbH/orgs","repos_url":"https://api.github.com/users/K2InformaticsGmbH/repos","events_url":"https://api.github.com/users/K2InformaticsGmbH/events{/privacy}","received_events_url":"https://api.github.com/users/K2InformaticsGmbH/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/K2InformaticsGmbH/imem","description":"Clustered in-memory database based on MNESIA with simple SQL layer","fork":false,"url":"https://api.github.com/repos/K2InformaticsGmbH/imem","forks_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/forks","keys_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/teams","hooks_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/hooks","issue_events_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/events{/number}","events_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/events","assignees_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/assignees{/user}","branches_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/branches{/branch}","tags_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/tags","blobs_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/refs{/sha}","trees_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/statuses/{sha}","languages_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/languages","stargazers_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/stargazers","contributors_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/contributors","subscribers_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/subscribers","subscription_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/subscription","commits_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/commits{/sha}","git_commits_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/git/commits{/sha}","comments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/comments{/number}","issue_comment_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/comments{/number}","contents_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/contents/{+path}","compare_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/merges","archive_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/downloads","issues_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues{/number}","pulls_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls{/number}","milestones_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/milestones{/number}","notifications_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/labels{/name}","releases_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/releases{/id}","deployments_url":"https://api.github.com/repos/K2InformaticsGmbH/imem/deployments","created_at":"2011-10-24T10:04:39Z","updated_at":"2016-01-01T10:11:45Z","pushed_at":"2016-03-09T11:07:32Z","git_url":"git://github.com/K2InformaticsGmbH/imem.git","ssh_url":"git@github.com:K2InformaticsGmbH/imem.git","clone_url":"https://github.com/K2InformaticsGmbH/imem.git","svn_url":"https://github.com/K2InformaticsGmbH/imem","homepage":"http://www.k2informatics.ch/","size":2305,"stargazers_count":2,"watchers_count":2,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":21,"forks":2,"open_issues":21,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76"},"html":{"href":"https://github.com/K2InformaticsGmbH/imem/pull/76"},"issue":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/76"},"comments":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/K2InformaticsGmbH/imem/statuses/1c757cdc8e17281b43230c393bef97307b28bfac"}}}}