[08:45:40] <Synt4x`> how do I append to a document? for instance if have a collection, and I want to find a certain document within that and add something to it
[10:22:17] <_roland> Hi all. I'm new to mongodb. I'm creating a REST service in Node using the Node.js MongoDB driver and I'm experiencing performance problems. I could use some guidance to improve performance.
[10:22:50] <_roland> The service supports a call to "profile" the data in a mongodb collection - basically to make a summary of all docs in a collection and present an inventory of the different types of docs found in the collection.
[10:23:47] <_roland> I tried 2 different approaches: 1 using find and then useing a cursor to update the profile; 2 using a map reduce job (using the mappper to update the profile and the reduce only to return the profile
[10:24:20] <_roland> I noticed that just the work of scanning the collection is much faster with map reduce (no surprise since the data doesnt get pulled to the client)
[10:25:02] <_roland> however, when the mapr job actually has to do something, it is in my case much slower (3x) than using the client side cursor.
[10:25:23] <_roland> I was wondering if someone could give me some advice on how to best troubleshoot performance.
[10:26:45] <_roland> Oh, final bit of information - when using the scan approach but not updating the profile I find that the work of profiling adds about 25% of extra work as opposed to simply scanning the collection with a cursor.
[10:27:07] <_roland> I'm at a loss as to why that same work executed in a mapr context can slow down the job so much.
[10:28:14] <_roland> my code for the profiler as map/reduce is here http://pastebin.com/x9R83hbJ
[15:02:39] <davidcsi> Hello all, I'm doing upserts to $push data into an array call packet. Is it possible to also add a top-level field? like "add this to the array field and add the top-level field?"
[15:06:31] <davidcsi> looks like i can't mix field updates/add with $push, i'm doing "u: { "deleted": "0", $push: { “field”: “whatever” } }" but this is not working...
[15:48:47] <Hw2k> hi, is there some good way that I can query mongo direcly from the terminal to see if a user exists for example?
[15:49:52] <Hw2k> I've tried with --eval, but it seems to return nothing(?), and I tried a syntax like 'echo "db.systems.users.find()" | mongo admin
[15:50:41] <Hw2k> the later seems to work, but I don't really understand why :)
[16:23:10] <clearcut> i have like 7000 quotes - i want to create fast search so that when user types in keyword he gets near-live search and filtering - what is the bes option for this fast searching and getting the results, mongodb/map-reduce / elastic search?
[17:34:50] <kali> i mean. _id contains whatever you put in it, or an ObjectId if you leave mongo pick whatever it wants. and ObjectId contains the timestamp
[19:18:11] <_roland1> Hi! I'm new to mongo. I'm trying to get a "data profile" of the documents stored in a single collection - a single object that summarizes what structures and datatypes are in there.
[19:18:51] <_roland1> I tried this in 2 different approaches - 1) map reduce 2) client cursor - the actual profiling code is more or less the same in both cases.
[19:19:36] <_roland1> currently both approaches are too slow - at least it feels it should be possible to speed it up; I'm looking for someone that could guide me a bit.
[19:21:14] <_roland1> kali: I'm confused as to how that can be, I epxected m/r to be faster since I don't have to pull the docs to the client.
[19:22:28] <_roland1> kali: I'm also looking for an efficient way to sample, as I do not want to be limited by the size of the dataset. iow I can afford to have it wrong sometimes as long as I can make some estimate as to how reliable my profile is.
[19:22:28] <kali> _roland1: well, first of all, mongodb focus is on making selective queries fast, so this code-path (full scan and map/reduce) are probably not as optimum as they could be
[19:28:11] <kali> wow, that's very nodish. how do you run it in map/reduce ?
[19:28:53] <_roland1> kali: well, lines 165 ..175 is that.
[19:29:11] <_roland1> kali: the actual code is in the scope var, "s".
[19:29:32] <_roland1> kali: the main method is updateProfile, which runs through the keys of the doc.
[19:29:57] <kali> why do you even bother using map/Reduce ?
[19:30:28] <kali> because you're basically just scanning the document there
[19:30:43] <_roland1> kali: I'm new to node. I don't know any better. I started with the client cursor, was unsatisfied with perf. I figured I could gain by not pulling docs to the client, enter m/r.
[19:31:16] <_roland1> kali: not just one document, a bunch. Currently the entire collection, in the future, hopefully only a sample.
[19:31:55] <_roland1> kali: my action is conceptually a reduction as I'm compressing info from all docs into one.
[19:32:21] <kali> you can try db.eval to run some javascript code in the server
[19:32:35] <kali> it could also be relevant to try it in the mongodb shell
[19:32:59] <_roland1> kali: that sounds like good advice, I shoul probably try that to see what I can expect in a best case.
[19:33:25] <_roland1> kali: I read about db.eval, haven't found the proper way to do that with the nodejs driver (yet.)
[19:33:38] <_roland1> All very new environments to me, still have to learn a lot.
[19:35:46] <kali> even if there is no helper for eval in the nodejs driver, you can always call it as a command
[19:36:34] <kali> but let me just make this is very clear: mongodb is not the good at doing that kind of stuff. it's not designed for that
[19:38:13] <_roland1> kali: thanks! Good to know. kali yeah I read about how you can alwyas fire a query to run a command. Might need to give that a try.
[19:54:19] <_roland1> kali: wow. That certainly makes a big difference. in the shell it's 800ms. Via node it's almost 5s.
[19:58:06] <_roland1> nope. ghost. actually about as fast in both cases.
[21:11:17] <_roland> kali: it's interesting. documents with long arrays seem to suffer substantially when I do them trhough map/reduce as compared to the cursor approach. can't really explain it, perhaps the BSON to JSON conversion is - for some reason - not very efficient for that particular case.
[21:12:06] <_roland> kali: anyway - thanks for the help. I think I can move on for now.
[22:14:19] <qswz> Hi, is it possible to search with a missing value, for example instead of find({'hello': 1}) I want to find({'hello': ?}) all items with a hello key, or find({?: 1}) all items with value 1
[22:15:03] <qswz> for find({'hello': ?}) I guess $exists can help