{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/3843","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/3843/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/3843/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/3843/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/3843","id":59122289,"number":3843,"title":"Reinstantiate automatic use of r.json","user":{"login":"danielmewes","id":505365,"avatar_url":"https://avatars.githubusercontent.com/u/505365?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmewes","html_url":"https://github.com/danielmewes","followers_url":"https://api.github.com/users/danielmewes/followers","following_url":"https://api.github.com/users/danielmewes/following{/other_user}","gists_url":"https://api.github.com/users/danielmewes/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmewes/subscriptions","organizations_url":"https://api.github.com/users/danielmewes/orgs","repos_url":"https://api.github.com/users/danielmewes/repos","events_url":"https://api.github.com/users/danielmewes/events{/privacy}","received_events_url":"https://api.github.com/users/danielmewes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/labels/tp:performance","name":"tp:performance","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/89","html_url":"https://github.com/rethinkdb/rethinkdb/milestones/2.0","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/89/labels","id":950901,"number":89,"title":"2.0","description":"","creator":{"login":"danielmewes","id":505365,"avatar_url":"https://avatars.githubusercontent.com/u/505365?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmewes","html_url":"https://github.com/danielmewes","followers_url":"https://api.github.com/users/danielmewes/followers","following_url":"https://api.github.com/users/danielmewes/following{/other_user}","gists_url":"https://api.github.com/users/danielmewes/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmewes/subscriptions","organizations_url":"https://api.github.com/users/danielmewes/orgs","repos_url":"https://api.github.com/users/danielmewes/repos","events_url":"https://api.github.com/users/danielmewes/events{/privacy}","received_events_url":"https://api.github.com/users/danielmewes/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":25,"state":"open","created_at":"2015-01-26T07:45:17Z","updated_at":"2015-02-28T00:50:21Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-02-26T18:57:58Z","updated_at":"2015-02-28T01:50:42Z","closed_at":null,"body":"We had another user running into a case where sending large documents to the server was extremely slow. It becomes much faster when wrapping the document into `r.json`, like we used to do before we switched away from protocol buffers.\r\n\r\nWe should put that logic back in, at least until we can fix https://github.com/rethinkdb/rethinkdb/issues/2900 which might be the reason for why things are slow without `r.json`.\r\n\r\nThis might also solve https://github.com/rethinkdb/rethinkdb/issues/2919 (depending on whether we use `r.json` automatically for `setUnion` arguments or just for `insert`/`replace` etc.).\r\n\r\nWould be nice to get it into 2.0\r\n(@Tryneus, @mlucy, @VeXocide any takers?)"},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/76503548","html_url":"https://github.com/rethinkdb/rethinkdb/issues/3843#issuecomment-76503548","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/3843","id":76503548,"user":{"login":"neumino","id":1461947,"avatar_url":"https://avatars.githubusercontent.com/u/1461947?v=3","gravatar_id":"","url":"https://api.github.com/users/neumino","html_url":"https://github.com/neumino","followers_url":"https://api.github.com/users/neumino/followers","following_url":"https://api.github.com/users/neumino/following{/other_user}","gists_url":"https://api.github.com/users/neumino/gists{/gist_id}","starred_url":"https://api.github.com/users/neumino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neumino/subscriptions","organizations_url":"https://api.github.com/users/neumino/orgs","repos_url":"https://api.github.com/users/neumino/repos","events_url":"https://api.github.com/users/neumino/events{/privacy}","received_events_url":"https://api.github.com/users/neumino/received_events","type":"User","site_admin":false},"created_at":"2015-02-28T01:50:42Z","updated_at":"2015-02-28T01:50:42Z","body":"I'm not sure that `r.json` is a good solution. The (removed) method `exprJSON` in the JS driver comes at a certain cost. You basically have to make sure that there's no ReQL term in your data and then call `r.json(JSON.stringify(...))`.\r\n\r\nIt used to be cheaper to do that than to build the protobuf object, but now that we don't have to create a datum for each value (except arrays), it's not obvious that this is more efficient. It's especially not in Node when the object has too many fields and v8 switch to a hash table to represent it.\r\n\r\nHaving something like `r.value(<json value>)` where `<json value>` does not contain a ReQL term (like r.now(), r.random() etc.) and (`r.value(...) = r.json(JSON.stringify(...))` would make more sense.\r\n\r\nYou can then have `insert` by default wrap its first argument with `r.value` and add a flag if people want to insert documents with ReQL terms."}}