PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 7th of October, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[03:16:34] <donCams> hi! say I have a collection with the following data {skills: [{name: 'foo', rating: 9}, {name: 'bar', rating: 8}]} and I want to query all documents where skill.name = 'foo' and its rating is greater than 5
[03:16:47] <donCams> how would I do that?
[03:21:17] <cheeser> $elemMatch
[03:25:54] <donCams> thanks cheeser
[03:27:39] <donCams> exactly what I needed
[03:28:28] <cheeser> any time
[03:31:19] <donCams> another thing. how does one sort by match score? do you know any example?
[03:32:14] <cheeser> i don't
[03:32:25] <donCams> cool. thanks. i'll google some more :)
[03:37:08] <jkretz> hi all
[03:37:14] <jkretz> anyone around?
[03:37:39] <joannac> yes
[03:37:44] <jkretz> i've just watched a webinar on dealing with time-based data in mongodb, and wanted to try to wrap my head around a few concepts if anyone is game
[03:39:12] <jkretz> essentially, the gist of the webinar was that inserts are expensive, updates are cheap - so instead of having a document per time-based record, it is smarter to have a document that spans some amount of time, and then update that document as new data comes in
[03:40:17] <jkretz> the example in the webinar setup a document that was storing hourly data - they had the data nested based on minutes 0 through 59 within the document
[03:40:50] <jkretz> i'm working with data that is very sparse, but i don't want to inherently lose time resolution if there were dense data in the system as well
[03:41:55] <jkretz> so i was thinking of designing my documents to be daily, based on hours, with each hour then having nested minutes, and each minute having seconds - but this seems like an absurd amount of overhead
[03:42:30] <jkretz> i guess i'm just curious if there is a known model that gracefully handles both dense and sparse time-based data
[03:44:03] <Boomtime> "inserts are expensive, updates are cheap (if the document does not grow in size nor change any index entires)"
[03:44:48] <Boomtime> if your document grows larger as a result of the update then it's disk location might require a move, that's a penalty that insert always takes
[03:45:03] <Boomtime> if your document changes index entries then that's another penalty that insert always takes
[03:45:35] <jkretz> hrmmm, pardon me as this is very much my first experience with mongodb - when you say the document grows, what do you mean? i'm appending data to the thing so i would assume it would grow...
[03:45:44] <Boomtime> if your update causes it to grow larger AND change index entries then it's basically an insert
[03:45:58] <Boomtime> your understanding is correct
[03:47:55] <jkretz> so is there anything i should be doing to design around the problem of the document moving?
[03:48:15] <Boomtime> if your document moves on disk it is possible for the penalty of the move to exceed that of an insert - though usually negligible difference
[03:49:26] <Boomtime> firstly, i assume you use 2.6, yes?
[03:50:21] <jkretz> yes i installed 2.6.4
[03:51:04] <Boomtime> ok, powerOf2Sizes is enabled by default then, document resizing will affect you less
[03:51:34] <Boomtime> however, if your documents change size significantly, as a percentage of their total size, then document moves still matter
[03:52:18] <Boomtime> one thing you can do is initialize your documents at a fair size of their eventual total, by creating all the fields/subdocuments you'll ever have
[03:52:23] <cheeser> powerof2 sizing will help mitigate this but only so much
[03:52:43] <jkretz> ah ok, this is what they meant by pre-allocating in the webinar
[03:52:48] <cheeser> right
[03:53:11] <jkretz> so essentially if i create the document with placeholder data for everything, i don't have to sweat the moves
[03:53:27] <Boomtime> that will likely reduce them
[03:53:33] <cheeser> jkretz: as much
[03:54:37] <Boomtime> if your placeholder data produces a document exactly the same size as a document will all the data filled in, then it will never move
[03:55:19] <jkretz> i should be able to do that - this is sensor data that is regularly the same size within any given time window
[03:55:31] <jkretz> barring comms failure
[03:55:41] <jkretz> are there problems related to making a document smaller?
[03:55:53] <Boomtime> none that i know of
[03:56:12] <Boomtime> it can lead to unnecessary disk consumption if that matters to you
[03:56:49] <Boomtime> since the space that is not in use as a result of the document reducing in size is not recycled until the document is deleted
[03:57:12] <jkretz> so, say i'm expecting 24 records within a day (hourly reporting) - i prepopulate the document with dummy data of the same size - but only receive 12 updates
[03:57:33] <jkretz> at the end of that window, removing the 12 original records of dummy data from the document is ok?
[03:57:42] <jkretz> (although i'm not sure why i would ha)
[03:57:47] <Boomtime> sure, the document won't move
[03:58:05] <jkretz> ok - cool - thanks again, just trying to wrap my head around the fundamentals here
[03:59:44] <jkretz> databases are not my area of expertise, i knew just enough to be a functional idiot in with sql - which i'm assuming will lead me astray more than once in the mongo world
[04:00:06] <jkretz> want to get started doing things the mongo way, rather than just translating sql and crying about bad performance
[04:01:41] <Boomtime> yeah, don't think about SQL, it does not translate well
[04:03:16] <Boomtime> @william_du: please ask your question here
[04:03:45] <william_du> how to obtain individual elements of an array (elements are embedded document) ?
[04:04:06] <william_du> i ,e :
[04:04:07] <william_du> {
[04:04:08] <william_du> "_id" : 2,
[04:04:08] <william_du> "people_id" : 2,
[04:04:08] <william_du> "albums" : [
[04:04:08] <william_du> {
[04:04:09] <william_du> "id" : 1,
[04:04:11] <william_du> "name" : "4",
[04:04:15] <william_du> "privilege" : 0,
[04:04:17] <william_du> },
[04:04:19] <william_du> {
[04:04:21] <william_du> "id" : 2,
[04:04:23] <william_du> "name" : "5",
[04:04:25] <william_du> "privilege" : 0,
[04:04:27] <william_du> }
[04:04:29] <william_du> ]
[04:04:31] <william_du> }
[04:04:33] <Xe> william_du: http://pastebin.com
[04:04:38] <Xe> also check your privilege
[04:04:56] <joannac> Is there a new session of a mongodb course?
[04:05:15] <joannac> This is the second or third time we've had this question in the last 8 hours
[04:05:30] <joannac> the answer is $elemMatch
[04:10:40] <joannac> actually, maybe the answer is http://docs.mongodb.org/manual/reference/operator/projection/slice/
[04:13:04] <Boomtime> william_du: do you want to know how to query for the presence of such a document based on the content of the array, or to return just an item from an array?
[04:13:31] <Boomtime> joannac's suggestion covers both those options
[04:17:18] <william_du> yes , the $elemMatch & $slice what is tried, but the result is expected for me
[04:17:20] <william_du> http://pastebin.com/Q7CYhiev
[04:18:00] <joannac> doesn't work like that
[04:18:12] <joannac> $elemMatch only matches one subdocument
[04:18:27] <joannac> you need to use the aggregation framework
[04:19:53] <Boomtime> also: "and conditions is (people_id  : 1 & privilege : 0)" <- typo? should be privilege 5 right?
[04:20:30] <william_du> yes , it should be 5
[04:50:09] <ispartan> Any one familiar with morphia here?
[04:56:50] <arussel> is there a way to check for the presence of an property that does not match a value ?
[04:57:40] <arussel> ie, with the following docs {a: {b:1, c:2}}, {a: {c:2}}, {a: {d:3, c:5}}
[04:58:04] <arussel> I want to find all the docs that have a a.*** property that is not c
[04:58:18] <arussel> so giving back the first and third doc
[05:11:01] <Boomtime> @arussel: no, you can't really do that - it would require a query on field names, rather than values - if you find yourself needing this, you probably have a schema problem
[05:11:38] <Boomtime> you could achieve what you want in the aggregation framework, if you don't mind a collection scan
[05:12:08] <Boomtime> (there is no index that could help you do what you want, you need to check every document directly)
[05:21:38] <no_mind> I am using Mongoose but when I ry to search in an array of objectId I do not get anresponse. Bu the same query on terminal gives correct response. What could be wrong ?
[05:22:12] <no_mind> I am using $in and id are wrapped in ctId() before being passed to query
[05:22:52] <Boomtime> sounds mongoose specific, if it works in the shell (which is an excellent way to test by the way)
[05:23:05] <Boomtime> sorry, i do not know mongoose, but it sounds like your on the right track
[05:23:12] <Boomtime> you're*
[05:23:27] <no_mind> where can I ask mongoose specific query ?
[05:24:02] <joannac> from their docs, irc: #mongoosejs on freenode
[05:52:42] <arussel> Boomtime: thanks, I'll just use a function (I'm migrating data, this is not a 'normal' call)
[06:48:45] <kakashiAL> hey guys, I am very new in mongoDB, installed my server and created a new collection with an object in it
[06:49:05] <kakashiAL> I am also able to find it
[06:49:46] <kakashiAL> so I started my mondo daemon/service with mongod -dbpath /myMongoData
[06:50:33] <kakashiAL> my question: I cant find my data there, I mean how are the collection stored
[06:50:38] <kakashiAL> not in a textfile?
[06:52:26] <joannac> they're stored in BSON which is binary, kakashiAL
[06:52:50] <joannac> you should be able to opena mongo shell and find the document
[07:22:28] <kakashiAL> joannac: is there an editor that let you open these files?
[07:28:41] <Boomtime> @kakashiAL: yes, it is called mongod
[07:30:03] <kakashiAL> mongod is the service, but if you mean there is an editor called like this, I will see what I cna find
[07:30:34] <Boomtime> no, i mean the service
[07:30:45] <kakashiAL> what I mean with editor: a pogramm that let you open the binaries files
[07:30:51] <Boomtime> mongod is the reader/writer of these files, modifying them externally is fraught with danger
[07:31:06] <Boomtime> what is wrong with using mongod for this purpose?
[07:31:23] <Boomtime> what is you expect from an "editor"?
[07:31:44] <Boomtime> maybe if you say what it is you want to do, we can recommend a client/gui program that does what you want
[07:32:19] <Boomtime> for example, many people like robomongo
[07:33:08] <kakashiAL> yes, something like this :)
[07:34:01] <Boomtime> so, robomongo is just a client, it connects to a mongod and provides you the access you a GUI like you see in screenshots here: http://robomongo.org/
[07:55:55] <krion> hello
[07:56:16] <krion> for a two nodes replicaSet, what's the best way to force a node to become primary ?
[07:57:11] <krion> is rs.stepDown() enough ?
[07:58:05] <cofeineSunshine> should be
[07:58:07] <cofeineSunshine> i think
[08:03:56] <krion> looks like from what i read, will try (in production)
[08:34:17] <krion> well
[08:34:23] <krion> the behaviour is kind of scary
[08:34:36] <krion> my goal is to get free space back
[08:34:51] <krion> that's why i force the secondary to become primary
[08:35:05] <krion> then i delete /data/db/mongodb (dbpath)
[08:35:14] <krion> but the behaviour is not the same as yesterday
[08:35:33] <krion> when i delete the data, the nodes goes from down to startup2
[08:35:43] <krion> and stay startup2 for a while
[08:45:41] <krion> but today, i do the same
[08:45:58] <krion> and the node is in recovering stat
[08:56:32] <t04D> stupid question: mms cannot allow people to backup standalone mongods ?
[08:56:44] <t04D> thats what I read in the documentation, Im just surprised
[08:57:43] <t04D> krion, how do you organize your backup solution ?
[08:57:47] <t04D> mongodump + rsync ?
[09:05:18] <krion> mongodump on the mongos on the primary node of the first replicaset
[09:05:36] <krion> the mongodump is executed from another vm in the customer perimeter
[09:08:18] <t04D> ok
[09:08:21] <t04D> the backup vm
[09:08:28] <t04D> but i mean
[09:08:32] <t04D> its manual work
[09:08:37] <t04D> not organized by a tool
[09:08:38] <krion> crontab
[09:08:42] <krion> nop
[09:08:44] <t04D> oki
[09:08:53] <krion> not PITR and stuff like that
[09:08:58] <t04D> because i was about to make dumps like stupid, but wondering if something existed
[09:09:10] <krion> don't oki me ! oki means ok idiot, and i'm not an idiot ;)
[09:09:15] <t04D> maybe a mongodump followed by a rsnapshot could be cool
[09:09:23] <t04D> yes you are !
[09:09:25] <t04D> :P
[09:09:48] <krion> looks like there is plenty of options available as i read, you could directly rsync data
[09:10:12] <t04D> never rsync something you have no idea if its being written on
[09:18:32] <krion> for sure, but i read stuff about it
[09:58:20] <krion> i'm wondering how to set priority in a replicaset with two nodes and one arbiter
[10:27:46] <krion> should i set a priority to the arbiter ? i doubt
[11:19:12] <BaNzoune1> Hey guys, when you pre allocating an array, what is the best value to use?
[11:33:07] <krion> i answer to myself: Hidden members, delayed members, and arbiters all have priority set to 0.
[12:01:37] <testerbit> I'm getting a couldn't connect to server error with mongo and mongotop even after a system reboot in ubuntu. How can I start mongodb or troubleshoot this issue?
[12:26:37] <ssarah> hei guys, im trying to start a: var rst = new ReplSetTest( { name: 'rsTest', nodes: 3 } ); rst.startSet()
[12:26:47] <ssarah> problem is, it goes away when i close the shell
[12:26:51] <ssarah> how do i make it more.. permanent?
[12:28:03] <t04D> sounds like you shouldnt use a 'Test'
[12:28:16] <t04D> but read the documentation about how to set up a real replication
[12:28:19] <Derick> ssarah: the ReplSetTest stuff is for internal testing
[12:28:25] <ssarah> arr
[12:28:29] <t04D> :D
[12:34:20] <ssarah> let check what i can do...
[12:36:29] <quattr8> I’m trying to create an index with TTL but getting this error since i upgraded mongodb to 2.6.4 -> bad index key pattern { 0: "created" }: Unknown index plugin 'created' on the PHP driver
[12:37:32] <quattr8> oh nvm that i forgot to set created to 1 instead of 0
[13:10:14] <ssarah> Guys, what I am founding is that you run "mongod --parameters" in one shell, then connect to that from another shell, define the rs and initiate it.
[13:10:44] <ssarah> but this way they all die when the shell dies. This is probably an easy thing, can ya get me a reference in the manual? =P
[13:19:39] <cheeser> on linux?
[13:19:50] <ssarah> yep yep, on linux, cheeser
[13:20:01] <cheeser> put & on the end of the mongod call
[13:21:01] <ssarah> cheeser: ah, i was trying "nohup mongo &", I don't use the nohup?
[13:22:39] <cheeser> i never have
[13:22:42] <cheeser> fwiw
[14:03:35] <ssarah> cheeser: if i start it with mongo & then i cant issue commands inside it, i'll have to connect remotely, right?
[14:05:24] <Derick> yes
[14:05:27] <Derick> with "mongo"
[14:05:40] <cheeser> you couldn't issue commands if you started mongod without the '&' either.
[14:06:03] <Derick> that's true too
[14:24:49] <berkley> I'm very new to Mongo, and I'm curious: if I'm building a database of archeological artifacts including loads of metadata plus pictures and/or 3D scans, do I store those pictures/3D scans as BSON, or do I store a reference to where they are stored on disk?
[14:25:42] <cheeser> you should look at gridfs
[14:26:38] <berkley> cheeser: Ooh, thanks for the tip
[15:46:24] <dgarstang> Is it possible to connect to mongos locally as the admin user without a password, even after one has been set?
[15:47:37] <cheeser> i don't think so
[15:47:51] <dgarstang> oh darn
[15:48:20] <dgarstang> i want a local script to add users, which runs againat localhost, but I have to put the admin password somewhere. Duh mongo
[15:50:13] <cheeser> yeah. duh security.
[16:44:46] <quattr8> will gridfs store a file with the same md5 twice?
[16:59:23] <skot> yes, there is no de-dup'n nor aliasing.
[18:35:45] <flatroze> Hello. I'm having trouble iterating through collections with native mongodb npm (not mongoose). I have a list of collections to go through and a `for()` loop with the find() and toArray() within it's block; but the collection_name variable behaves very strange with .toArray()
[21:09:42] <mst1228> hey, i have a model and one of it's fields is an ObjectId relating it to another model. how can i use the $nin operator with ObjectIds?
[21:10:07] <mst1228> i tried {tap: {$nin: ["5413799c28670477e5e169f4", "541379a828670477e5e169f5]}}
[21:10:20] <mst1228> i dont think it likes how those ids are formatted maybe?
[21:10:47] <Boomtime> those are strings
[21:11:36] <Boomtime> in the shell, an ObjectId would be ObjectId("5413799c28670477e5e169f4")
[21:12:17] <mst1228> ahh
[21:12:21] <mst1228> great, thanks a ton Boomtime
[21:38:38] <stefandxm> hmm
[21:38:57] <stefandxm> i cant find proper documentation for basic functionality in c++ driver
[21:39:04] <stefandxm> where should i look ? :)
[23:27:12] <hydrajump> hi
[23:28:52] <hydrajump> I have a 3 member replica set and I want to migrate the data to 3 new instances. If I add 3 new members to the existing replica set, waiting for replication to complete and than promote a new one to primary and remove the old 3 members is this the best approach without resorting to downtime?
[23:34:11] <Boomtime> @hydrajump: that will certainly work
[23:35:21] <Boomtime> "beat approach" is a subjective term, the method you describe is the easiest and probably safest
[23:39:10] <hydrajump> Boomtime: how can I ensure that the new members have been replicated successfully and that the data is consistent with the old 3 members before I demote them and stop them?
[23:40:51] <Boomtime> the new members will only enter SECONDARY status once they have replicated fully and closely caught up
[23:41:21] <Boomtime> once the new members have alkl entered SECONDARY status, set one of them to a higher priority (reconfig)
[23:41:52] <Boomtime> the replica-set will elect the higher priority member to be PRIMARY once it is able to
[23:42:01] <Boomtime> voila
[23:49:52] <hydrajump> Boomtime: ok and if the old replica set is on 2.4.4 which I was told has replication issues how will I know that the data will replicate successfully to the new 2.4.11 members? Is there any comparison commands I can run between old and new?
[23:50:07] <hydrajump> Or do I just "trust" the mongodb will take care of it?
[23:51:35] <Boomtime> for that version of mongodb you should probably add one new member at a time and wait for it to transition into SECONDARY
[23:51:45] <hydrajump> oh ok
[23:52:02] <Boomtime> this way you only ever have 1 voting member in an initial-sync state
[23:52:43] <Boomtime> replication will be fine, it works in 2.4.4 as it ever did, but there some problems surrounding elections and when members can vote etc
[23:53:04] <hydrajump> ok and the mongod.conf needs to be identical between all 6 members, e.g. dbpath, log path etc?
[23:53:14] <Boomtime> no
[23:53:29] <Boomtime> --replSet parameter needs to be the same, that is all
[23:53:34] <hydrajump> ok so I can tweak it on the new members that's great.
[23:53:54] <hydrajump> any way to gauge how long 20GB will take to replicate?
[23:54:16] <Boomtime> not really unfortunately, depends on many factors
[23:54:46] <hydrajump> ok I'll start tomorrow in the morning and cross my fingers.
[23:54:56] <Boomtime> network speed and latency, hard-drive speed, ongoing system load, number of indexes...
[23:56:10] <hydrajump> Right thanks for your advice Boomtime!