[SERVER-3107] For JS, add a findRO() that returns a read-only object, which can be much faster for certain cases Created: 16/May/11  Updated: 12/Jul/16  Resolved: 26/May/11

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 1.9.1

Type: New Feature Priority: Major - P3
Reporter: Antoine Girbal Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-3629 ensure that find readonly is implemen... Closed
related to SERVER-3631 modifying a non object member of a re... Closed
Participants:

 Description   

if doing a find/read or find/insert in JS code, the JS object is considered writable.
This makes it slower for read access, and also on insert() whole object is translated back an forth to JS.
For example:
db.col.find.foreach(function(d)

{db.col2.insert(d)}

)
will convert entire object from bson to JS then JS to bson.
Instead if an obj is explicitly marked as RO, we can reuse the exact same BSON.



 Comments   
Comment by Antoine Girbal [ 26/May/11 ]

implemented as .readOnly() on cursor.
Only works in v8.
Checked that the same BSON is reused.

Comment by auto [ 26/May/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-3107: readOnly option to JS cursor, to reuse BSON as-is
Fixed named properties enumerator for readonly v8 object
Branch: master
https://github.com/mongodb/mongo/commit/c775f5f250f9daa9bad803f738a5f6f351f4ca15

Comment by Scott Hernandez (Inactive) [ 16/May/11 ]

What about find().readOnly() instead?

Generated at Thu Feb 08 03:02:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.