{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/comments/37969253","id":37969253,"diff_hunk":"@@ -431,7 +425,50 @@ dbu.buildGetQuery = function(tableName, query, schema, includePreparedForDelete)\n         }\n         sql += condition + constructOrder(query, schema) + limit;\n     }\n-    return {sql: sql, params: params};\n+    return sql;\n+};\n+\n+function extractConditionParams(query, schema) {\n+    var params = [];\n+    var pred = query.attributes;\n+    Object.keys(pred).forEach(function(predKey) {\n+        var predObj = pred[predKey];\n+        if (!predObj || predObj.constructor !== Object) {\n+            params.push(schema.converters[schema.attributes[predKey]].write(predObj));\n+            pred[predKey] = null;\n+        } else {\n+            var predKeys = Object.keys(predObj);\n+            var predOp = predKeys[0];\n+            var predArg = predObj[predOp];\n+            if (predOp.toLowerCase() === 'between') {\n+                params.push(schema.converters[schema.attributes[predKey]].write(predArg[0]));\n+                params.push(schema.converters[schema.attributes[predKey]].write(predArg[1]));\n+                predArg[0] = null;\n+                predArg[1] = null;\n+            } else {\n+                params.push(schema.converters[schema.attributes[predKey]].write(predArg));\n+                predObj[predOp] = null;\n+            }\n+        }\n+    });\n+    return params;\n+}\n+\n+dbu.extractGetParams = function(query, schema, includePreparedForDelete) {\n+    var params;\n+    if (query.attributes) {\n+        params = extractConditionParams(query, schema);\n+    } else {\n+        params = [];\n+    }\n+\n+    // Also include check that _exist_until not expired\n+    if (includePreparedForDelete) {\n+        params.push(new Date().getTime());\n+    } else {\n+        query.includePreparedForDelete = false;","path":"lib/dbutils.js","position":66,"original_position":66,"commit_id":"59337f2e1abfa801b02b2974c0aae1d4f82bd53b","original_commit_id":"59337f2e1abfa801b02b2974c0aae1d4f82bd53b","user":{"login":"d00rman","id":10210173,"avatar_url":"https://avatars.githubusercontent.com/u/10210173?v=3","gravatar_id":"","url":"https://api.github.com/users/d00rman","html_url":"https://github.com/d00rman","followers_url":"https://api.github.com/users/d00rman/followers","following_url":"https://api.github.com/users/d00rman/following{/other_user}","gists_url":"https://api.github.com/users/d00rman/gists{/gist_id}","starred_url":"https://api.github.com/users/d00rman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d00rman/subscriptions","organizations_url":"https://api.github.com/users/d00rman/orgs","repos_url":"https://api.github.com/users/d00rman/repos","events_url":"https://api.github.com/users/d00rman/events{/privacy}","received_events_url":"https://api.github.com/users/d00rman/received_events","type":"User","site_admin":false},"body":"When is this ever set to `true` ?","created_at":"2015-08-26T10:59:12Z","updated_at":"2015-08-26T10:59:12Z","html_url":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12#discussion_r37969253","pull_request_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/comments/37969253"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12#discussion_r37969253"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12","id":42029500,"html_url":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12","diff_url":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12.diff","patch_url":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12.patch","issue_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/12","number":12,"state":"open","locked":false,"title":"Cache prepared statements for get requests","user":{"login":"Pchelolo","id":814754,"avatar_url":"https://avatars.githubusercontent.com/u/814754?v=3","gravatar_id":"","url":"https://api.github.com/users/Pchelolo","html_url":"https://github.com/Pchelolo","followers_url":"https://api.github.com/users/Pchelolo/followers","following_url":"https://api.github.com/users/Pchelolo/following{/other_user}","gists_url":"https://api.github.com/users/Pchelolo/gists{/gist_id}","starred_url":"https://api.github.com/users/Pchelolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pchelolo/subscriptions","organizations_url":"https://api.github.com/users/Pchelolo/orgs","repos_url":"https://api.github.com/users/Pchelolo/repos","events_url":"https://api.github.com/users/Pchelolo/events{/privacy}","received_events_url":"https://api.github.com/users/Pchelolo/received_events","type":"User","site_admin":false},"body":"This is an implementation of an idea to cache db prepared statements. This gives ~20% improvement in read speed (from 290s to 240s for 100000 requests to a restbase endpoint). While being great for reads, it's unnecessary for writes, as we don't have that much of them and it's better to keep code cleaner.","created_at":"2015-08-10T15:02:04Z","updated_at":"2015-08-26T10:59:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32ed12342ba7fbaea7355332361cd8945520c4f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12/commits","review_comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12/comments","review_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/12/comments","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/statuses/59337f2e1abfa801b02b2974c0aae1d4f82bd53b","head":{"label":"Pchelolo:cache","ref":"cache","sha":"59337f2e1abfa801b02b2974c0aae1d4f82bd53b","user":{"login":"Pchelolo","id":814754,"avatar_url":"https://avatars.githubusercontent.com/u/814754?v=3","gravatar_id":"","url":"https://api.github.com/users/Pchelolo","html_url":"https://github.com/Pchelolo","followers_url":"https://api.github.com/users/Pchelolo/followers","following_url":"https://api.github.com/users/Pchelolo/following{/other_user}","gists_url":"https://api.github.com/users/Pchelolo/gists{/gist_id}","starred_url":"https://api.github.com/users/Pchelolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pchelolo/subscriptions","organizations_url":"https://api.github.com/users/Pchelolo/orgs","repos_url":"https://api.github.com/users/Pchelolo/repos","events_url":"https://api.github.com/users/Pchelolo/events{/privacy}","received_events_url":"https://api.github.com/users/Pchelolo/received_events","type":"User","site_admin":false},"repo":{"id":38808474,"name":"restbase-mod-table-sqlite","full_name":"Pchelolo/restbase-mod-table-sqlite","owner":{"login":"Pchelolo","id":814754,"avatar_url":"https://avatars.githubusercontent.com/u/814754?v=3","gravatar_id":"","url":"https://api.github.com/users/Pchelolo","html_url":"https://github.com/Pchelolo","followers_url":"https://api.github.com/users/Pchelolo/followers","following_url":"https://api.github.com/users/Pchelolo/following{/other_user}","gists_url":"https://api.github.com/users/Pchelolo/gists{/gist_id}","starred_url":"https://api.github.com/users/Pchelolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pchelolo/subscriptions","organizations_url":"https://api.github.com/users/Pchelolo/orgs","repos_url":"https://api.github.com/users/Pchelolo/repos","events_url":"https://api.github.com/users/Pchelolo/events{/privacy}","received_events_url":"https://api.github.com/users/Pchelolo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Pchelolo/restbase-mod-table-sqlite","description":"SQLite backend for RESTBase","fork":true,"url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite","forks_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/forks","keys_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/teams","hooks_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/hooks","issue_events_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/issues/events{/number}","events_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/events","assignees_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/assignees{/user}","branches_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/branches{/branch}","tags_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/tags","blobs_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/statuses/{sha}","languages_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/languages","stargazers_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/stargazers","contributors_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/contributors","subscribers_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/subscribers","subscription_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/subscription","commits_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/contents/{+path}","compare_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/merges","archive_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/downloads","issues_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/issues{/number}","pulls_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/pulls{/number}","milestones_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/milestones{/number}","notifications_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/labels{/name}","releases_url":"https://api.github.com/repos/Pchelolo/restbase-mod-table-sqlite/releases{/id}","created_at":"2015-07-09T08:36:38Z","updated_at":"2015-07-15T21:31:46Z","pushed_at":"2015-08-26T09:44:59Z","git_url":"git://github.com/Pchelolo/restbase-mod-table-sqlite.git","ssh_url":"git@github.com:Pchelolo/restbase-mod-table-sqlite.git","clone_url":"https://github.com/Pchelolo/restbase-mod-table-sqlite.git","svn_url":"https://github.com/Pchelolo/restbase-mod-table-sqlite","homepage":"https://www.mediawiki.org/wiki/RESTBase","size":240,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"wikimedia:master","ref":"master","sha":"7e2013af35084cbea695ef69cb00419d133d76ce","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":30235380,"name":"restbase-mod-table-sqlite","full_name":"wikimedia/restbase-mod-table-sqlite","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/restbase-mod-table-sqlite","description":"SQLite backend for RESTBase","fork":false,"url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite","forks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/forks","keys_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/teams","hooks_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/events","assignees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/tags","blobs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/languages","stargazers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/subscription","commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/merges","archive_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/downloads","issues_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/releases{/id}","created_at":"2015-02-03T09:34:13Z","updated_at":"2015-07-21T21:59:01Z","pushed_at":"2015-08-26T09:45:01Z","git_url":"git://github.com/wikimedia/restbase-mod-table-sqlite.git","ssh_url":"git@github.com:wikimedia/restbase-mod-table-sqlite.git","clone_url":"https://github.com/wikimedia/restbase-mod-table-sqlite.git","svn_url":"https://github.com/wikimedia/restbase-mod-table-sqlite","homepage":"https://www.mediawiki.org/wiki/RESTBase","size":441,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12"},"html":{"href":"https://github.com/wikimedia/restbase-mod-table-sqlite/pull/12"},"issue":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/12"},"comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/restbase-mod-table-sqlite/statuses/59337f2e1abfa801b02b2974c0aae1d4f82bd53b"}}}}