PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 15th of June, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:00:28] <sector_0> StephenLynx, cool thanks
[00:23:57] <jgornick> StephenLynx: I finally found a solution to what I was trying to do: https://gist.github.com/jgornick/eace131a44a2b594d51f1b3d9f94e6ca
[00:24:54] <StephenLynx> wait wait
[00:24:56] <jgornick> The update will pull out any history items that are older than 5 minutes.
[00:25:01] <StephenLynx> you are clearing the collection before anything?
[00:25:10] <jgornick> StephenLynx: It's just a test.
[00:25:18] <jgornick> So I can re-insert my data.
[00:25:51] <StephenLynx> it still doesn`t remove multiple elements from the same sub-array, does it?
[00:25:51] <jgornick> The gist of the gist, ha funny, is to show the schema and the update statement :)
[00:25:59] <jgornick> StephenLynx: Yes it does.
[00:26:02] <StephenLynx> hm
[00:26:15] <StephenLynx> ah
[00:26:19] <StephenLynx> maybe its the elemMatch
[00:26:28] <jgornick> Because $pull is pulling items from the history array that match a condition.
[00:26:38] <jgornick> Which it's pulling all items that match that condition.
[00:45:29] <klaxa> hi, i must be stupid: https://gist.github.com/klaxa/04cb745b9955ab45a85464f19cc8da3d
[00:45:41] <klaxa> i'm getting duplicate key errors for non-duplicate keys?
[00:46:26] <klaxa> the first file is demonstrating how i get the duplicated keys error, the second file is the index i created and the third file is the pythoncode (pymongo) i used to create said index (not that it should matter really)
[00:46:42] <klaxa> oh, github changed the order
[00:51:47] <klaxa> it appears that keys may not even share parts?
[00:52:02] <klaxa> if i change the value of "path" to something that doesn't include "music" it works
[00:57:50] <Boomtime> @klaxa: i'm not sure a unique 'text' index could possibly be what you want.. i didn't even know that was possible
[00:58:10] <klaxa> yeah, it seems like it
[00:58:23] <klaxa> it's apparently something very different from what i thought
[00:58:31] <Boomtime> https://docs.mongodb.com/manual/core/index-text/
[00:59:02] <Boomtime> your answer is probably here -> https://docs.mongodb.com/manual/core/index-text/#index-entries
[00:59:25] <Boomtime> that explains why you get dup key violations - the index contains a lot more entries than you think
[00:59:47] <klaxa> oooh, i see now
[01:00:37] <klaxa> so i'm guessing it's building a reverse index with the strings tokenized to find stuff faster
[01:01:01] <klaxa> thanks, guess i'll teach my application to avoid duplicates then
[01:01:16] <Boomtime> right, you're asking for a unique constraint on the combination of every stem in the text field combined with the second field
[01:01:36] <Boomtime> why does it need to be 'test'?
[01:01:39] <Boomtime> text*
[01:01:43] <klaxa> what i want is a unique constraint on the untokenized string, is that possible?
[01:01:53] <klaxa> it's a path to a file
[01:01:54] <Boomtime> yeah, just don't be a 'text'
[01:02:02] <klaxa> but a string?
[01:02:13] <klaxa> ah
[01:02:28] <Boomtime> { _fts: 1, _ftsx: 1 }
[01:03:19] <Boomtime> mongodb doesn't care what the value is, it just indexes whatever is there - when you say 'text' you are asking mongodb to explicitly inspect the type and deconstruct it as a tokenized string field
[01:05:02] <klaxa> yeah, i get it now, text is a special case of string (which is just a special case of data)
[01:05:11] <Boomtime> :D
[01:07:43] <klaxa> thanks, got it working now :)
[01:48:30] <sector_0> I have a database that stores user information, and I have need for a user id (or something to that effect), should I use the _id field for this, rather than make a separate userID field?
[01:49:31] <sector_0> are there any reasons not to do this?
[01:49:52] <sector_0> ..keeping in mind this field gets exposed to the client
[01:51:21] <StephenLynx> if you are fine with the _id format
[01:51:25] <StephenLynx> go for it.
[01:51:37] <StephenLynx> otherwise if its something readable that you wish
[01:51:58] <StephenLynx> you might want to create a separate unique index and use a different field
[02:00:55] <Boomtime> @sector_0: be aware that _id is also just a field like any other, you can specify your own value for it
[02:01:26] <sector_0> Boomtime, yeah I know
[02:01:33] <Boomtime> goodo
[02:01:59] <sector_0> StephenLynx, well I was more concerned about memory usage
[02:02:16] <StephenLynx> eh
[02:02:37] <StephenLynx> I don`t think it would be relevant.
[02:03:00] <sector_0> StephenLynx, I know, but if I can compress 2 fields into one...why not
[02:03:32] <StephenLynx> because you might end up saving cycles by using a separate field.
[02:03:52] <sector_0> StephenLynx, how so?
[02:03:52] <StephenLynx> for example
[02:04:03] <StephenLynx> lets say you want to give the user something friendly
[02:04:09] <StephenLynx> or even that he can manually type
[02:04:15] <StephenLynx> if all you got is _id
[02:04:28] <StephenLynx> you will have to get to the db a second time to get this friendly field.
[02:04:41] <StephenLynx> while if you use this field as an index in the first place, you don`t have to do that.
[02:06:04] <cheeser> generally speaking _id values should have 0 business value.
[02:06:31] <StephenLynx> I also like to use _ids sometimes.
[02:07:16] <StephenLynx> when I don`t have to worry about readability at all
[02:08:01] <sector_0> StephenLynx, well I also don't need to worry about readability
[02:08:29] <StephenLynx> then id use _id
[08:30:05] <shayla> Hi guys. I've got the following query : http://pastebin.com/BpR1GNPu What I need is to make the count ($sum : 1) only for field that respect some $match condition but I don't want to add it on the general $match to the query but just for the count. Is there a way to do it on the same query or I need to do two distinct query?
[08:30:06] <shayla> Thanks
[09:18:28] <alias_> Hi is there any way to have mongo log in gelf or json format?
[09:44:58] <jelle> I have an issue with showing some stats data to customers, the initial query is slow, but doing it the second time it's super fast. Any tips how I can make the initial query faster? (I'm using a hdd backend mongodb)
[09:45:23] <jelle> I havne't checked if the first query has a lot of page faults but I guess it does
[10:03:27] <jelle> nevermind, seems I did set some wrong indexes
[11:46:37] <kknight> I have made an app . Now I want to make a new collection for a model .. how to do that?
[11:49:03] <Zelest> just write to it
[11:49:23] <kknight> i am not getting any help from documentation
[11:49:38] <Zelest> db.blargh.insert() will create blargh automagically
[11:50:02] <kknight> also i am looking some ui like php myadmin for 32 bit gnome
[11:50:26] <kknight> i think from there i can create new collections easily
[11:53:30] <kknight> :((
[13:23:21] <shayla> Hi guys, i'm having a problem working with mongodb. This is what I do in mongodb family: {$sum: { $cond: [ { $eq: ["$content.products.product", 99] }, 1, 0 ] } } . I need to do that query in php so i do something like 'family' => ['$sum' => ['$cond' => ['$eq' => ['$content.products.product', 99]], 1, 0]]
[13:23:31] <shayla> But it doesn't work
[13:23:37] <shayla> Any suggestion? Thanks.
[13:37:27] <jayjo_> I have a field in my document that is a UTC timestamp in seconds (since the epoch). Is there a way to interact with dates in a query document, or do I have find what time in seconds is certain date marks and go from there? For a concrete example, to get all records from the last day or something similar
[13:41:27] <StephenLynx> store as an actual date object.
[13:41:34] <StephenLynx> instead of a string representing a date.
[13:44:06] <jayjo_> This data is from a provider that exports to json. Is there a way to have it automatically convert? Or do I run something periodically to convert it?
[13:47:33] <jayjo_> But at least the field is an integer
[13:49:16] <StephenLynx> that depends on your driver.
[13:49:33] <StephenLynx> with the node.js driver you just give it a date object that the driver handles the conversion.
[14:00:26] <saml> new Date(provider['date'])
[14:08:12] <m1dnight_> when I do db.collection.find().sort(..);, does that do the sort in the db engine, or does it first fetch the entire table and then sort in memory?(outside of the db)
[14:32:02] <kurushiyama> m1dnight_ That depends on your setup and your indices. (and order in which you give the sort params)
[14:54:26] <jayjo_> So, the data is already inserted using mongoimport, and the _t field is an integer. I can use .forEach() in the mongo console. Is there a way to automate this within mongo or do I just set a cronjob to execute periodically? Like in sql I could use triggers or view functions - is there an analog?
[14:54:50] <jayjo_> to be clear- still trying to get an integer into ISODate()
[14:59:21] <StephenLynx> you will have to handle that on application code.
[15:10:00] <jayjo_> Can I use anonymous functions in the javascript shell? liek this: { _t : { $gt: function() { var d = new Date(); d.setDate(d.getDate() - 2); return d.getTime(); } } }
[15:59:55] <scmp> Hi, what does it mean when explain() returns a winningPlan with "EOF" ?
[16:01:28] <hardwire> scmp: https://docs.mongodb.com/manual/reference/explain-results/
[16:01:32] <hardwire> search 'isEOF'
[16:03:08] <scmp> meaning there are no results?
[16:03:15] <hardwire> :|
[16:03:38] <hardwire> it says right in the docs.
[16:05:29] <scmp> end of what stream? the docs could be a little bit more specific. And stream is not mentioned anywhere else.
[16:06:05] <scmp> it's a large collection, a simple query if field a exists and field does not exists, and a combined index on both fileds, not sparse.
[16:06:12] <hardwire> look at what the false description says
[16:06:23] <hardwire> true is the opposite.
[16:11:04] <hardwire> The docs DO cover it. But I think you may want the functionality to meet some expectations that aren't described.. and I'm not sure there's more to say about that flag.
[16:12:17] <scmp> well, there is no limit() on that query
[16:13:27] <scmp> what i expect is that winningPlan mentions the index and i don't understand why it's not able to select the index
[16:15:27] <scmp> does mongo have an default limit() ?
[16:15:57] <scmp> it is a large collection, but it's also a very simple query and index
[16:16:13] <StephenLynx> default?
[16:21:26] <idioglossia> StephenLynx, he means if the collection is super big, does mongo limit the query to return, say, the first N items (where N is extremely large but not infinite) instead of returning all of them
[16:21:50] <idioglossia> oh he left
[16:21:52] <idioglossia> lel
[16:35:33] <kurushiyama> idioglossia No, mongodb does not limit the items by default.
[16:38:43] <StephenLynx> the other dude asked
[16:38:52] <StephenLynx> but said dude left
[16:39:26] <StephenLynx> idi was just explaining to me what dude asked.
[17:00:46] <sinkmanu> hi
[18:22:07] <kurushiyama> StephenLynx Well, I am a bit slowish today.
[18:22:17] <kurushiyama> sinkmanu Hi.
[18:36:11] <hardwire> moo
[18:46:40] <deostroll> Hi. Anyone out here can answer this question: http://softwarerecs.stackexchange.com/q/33891/8530
[18:47:28] <StephenLynx> anyone that support indexes, I think.
[18:48:26] <StephenLynx> get document with field X, on the next query, ask for the minimum value of X to be the highest X you got on the first query
[18:48:34] <StephenLynx> this is how you do paging in mongo, btw.
[18:48:44] <StephenLynx> since skips are relatively slow.
[18:49:45] <StephenLynx> not to mention that you are able to sort too
[18:53:01] <deostroll> was that for me?
[18:54:30] <StephenLynx> yes
[18:55:02] <StephenLynx> you will have to lay out more requirements so people can recommend a db.
[18:55:23] <StephenLynx> sequential access is pretty much a standard feature of anything reading data.
[18:55:55] <deostroll> there are rest api's that somehow give that feature out of the box...
[18:56:08] <deostroll> for e.g. sleepy mongoose
[18:56:38] <deostroll> however, I didn't find anything in the mongodb api to that effect...?
[18:57:57] <StephenLynx> dont use mongoose
[18:58:03] <deostroll> in the shell I've tried setting batchSize, but instead it returned all the documents
[18:58:20] <StephenLynx> you want to limit the amount of results? use limit on the cursor.
[18:59:33] <deostroll> Sleepy mongoose, not mongoose
[18:59:35] <deostroll> https://github.com/mongodb-labs/sleepy.mongoose/wiki/Getting-More-Results
[18:59:58] <StephenLynx> wtf
[19:00:17] <StephenLynx> that sounds like a nightmare.
[19:01:12] <StephenLynx> it seems to just expose your database as an api?
[19:01:34] <StephenLynx> sounds EXTREMELY exploitable.
[19:02:09] <deostroll> yeah, I agree...you probably need some auth mechanisms over it...
[19:03:09] <deostroll> but the main benefit is that clients can rely on REST to do CRUD stuff
[19:03:42] <StephenLynx> I really don't see that as a benefit at all.
[19:04:17] <StephenLynx> the other day had one guy here that was neck deep in trouble because of users crud'ing directly
[19:04:38] <StephenLynx> killing the database with overly complex queries and asking him to just fix it.
[19:04:48] <deostroll> my c# client, for e.g. needs those drivers/libraries installed; if I were to talk to direct mongodb
[19:05:21] <StephenLynx> you would get more trouble than its worth.
[19:06:05] <deostroll> anyway coming to the point...
[19:06:24] <deostroll> what is the equivalent of a cursor_id in the mongodb api?
[19:06:37] <StephenLynx> there isn't an api.
[19:06:49] <StephenLynx> not a high level one.
[19:06:58] <StephenLynx> the api that exists is meant for you to develop a driver on top of it.
[19:07:33] <StephenLynx> and said driver would just implement mongo's protocol using TCP.
[19:07:59] <StephenLynx> so you would just connect using a driver.
[19:09:08] <deostroll> but what is the equivalent of a cursor_id in a cursor object?
[19:10:38] <deostroll> so if at all I need to get the next set of records from the cursor after I've exhausted it...
[19:11:27] <StephenLynx> that depends on the driver.
[19:11:39] <StephenLynx> on the node driver you just keep the cursor in a variable.
[19:12:35] <StephenLynx> however
[19:12:54] <StephenLynx> you said that you have exhausted it. in that case you don't do anything else with the cursor.
[19:12:56] <StephenLynx> you open a new one.
[19:13:11] <StephenLynx> and query it in a way that it will give you the data you need.
[19:13:36] <jgornick> Hey folks, is it fair to say that appending a value to an array is going to be much more performant than prepending?
[19:13:51] <StephenLynx> jgornick, no idea.
[19:14:01] <StephenLynx> it depends on the array implementation
[19:14:42] <StephenLynx> besides, when you edit documents, I heard that the bottleneck lies on updating indexes if the document size changes enough.
[19:15:48] <jgornick> StephenLynx: Based on that information, it doesn't matter if you prepend or append.
[19:15:57] <jgornick> ... at least it sounds that way.
[19:16:46] <StephenLynx> exactly
[19:20:08] <StephenLynx> however
[19:20:21] <StephenLynx> if I remember correctly, you don't have different operators for insertion.
[19:20:34] <StephenLynx> addToSet will push it wherever.
[19:20:38] <StephenLynx> jgornick
[19:20:51] <t3chguy> Hello, I'm just getting acquainted to Mongo, and am wondering whether I can use db.collection.save with $currentDate to be able to track a modifiedDate value with the document;- Cheers
[19:20:59] <StephenLynx> so you push add it and that's it.
[19:21:09] <StephenLynx> if you want it sorted, you will have to do it on application code.
[19:21:28] <jgornick> StephenLynx: Yeah, that's what I'll have to do because there are situations where I want it sorted.
[19:21:39] <StephenLynx> feel ya.
[19:21:49] <StephenLynx> had the same thing one time.
[19:22:36] <StephenLynx> t3chguy, that sounds a lot like a standard upsert.
[19:26:45] <t3chguy> StephenLynx: so would I just shove the whole document as the $set and its _id as the query?
[19:29:40] <StephenLynx> hm, heres the tricky part
[19:29:54] <StephenLynx> for you to use an _id you would have to generate an ObjectId
[19:30:06] <StephenLynx> and no, you can also use $setOnInsert
[19:47:12] <t3chguy> StephenLynx: all my documents are pre-existing, so wouldn't even need to upsert, I have a task that needs to go through each and update some, thus .save would have been ideal for its syntax of just being the document itself but I also need to update the modifiedDate
[19:48:23] <StephenLynx> hm
[19:48:34] <StephenLynx> it seems that save is meant for the same than upserts.
[19:49:14] <StephenLynx> an update that isn't marked to update many or if it uses an indexed field to find the documents to be updates are optimized.
[19:49:21] <StephenLynx> is optimized*
[19:49:38] <StephenLynx> updated**
[19:50:01] <StephenLynx> id just use update.
[19:52:23] <sequence> Hey channel, is there an existing solution for resilience in the face of a replica set primary being stepped down? Something like a smart driver that will reconnect and reissue queries, or a MITM proxy (like dvara)?
[19:55:26] <GothAlice> sequence: AFIK every official driver already does this.
[19:56:37] <sequence> GothAlice: looking at something like https://emptysqua.re/blog/save-the-monkey-reliably-writing-to-mongodb/, it seems like reconnecting and reissuing is something the (Python in this case) client has to take care of.
[19:57:10] <sequence> Even though that is quite old, I'm still seeing Exceptions with our use of the Java driver (3.2.2)
[19:57:51] <sequence> `rs.stepDown()` triggers a `com.mongodb.MongoSocketReadException: Prematurely reached end of stream`
[19:58:26] <GothAlice> sequence: http://api.mongodb.com/python/current/api/pymongo/mongo_client.html < note the paragraph under the MongoClient() constructor section at the top starting with "The client object is thread-safe and has connection-pooling built in."
[19:58:56] <GothAlice> You *do not* want the driver automatically re-trying every query. The results could be disastrous.
[19:59:39] <Derick> GothAlice: no driver should attempt to re-issue a write when a connection breaks down, or a new node gets elected as primary
[19:59:49] <GothAlice> Derick: Quite so.
[20:00:02] <sequence> I agree too
[20:00:06] <GothAlice> The application must decide for itself what to do in that situation.
[20:00:11] <kurushiyama> An $inc is just the most obvious example...
[20:00:15] <sequence> I guess I'll have to rethink from a higher level
[20:00:15] <Derick> OK - your answer at 20:46 was confusing to me then :)
[20:01:03] <GothAlice> Derick: Er, timezones? 20:46 is in my future. ;P
[20:01:28] <Derick> 6 mins ago
[20:01:33] <GothAlice> Derick: Ah, found it. Indeed, I was referring primarily to the "reconnect" part of the query, not the "reissue" part.
[20:03:50] <GothAlice> sequence: At work we divide our queries into a matrix of risk. One dimension revolves around write concern, another around pattern of retry. From "no need to retry, failure is OK" through "retry is trivial, just repeat the operation" (a la $set), to "yowza, we need to run some custom code to determine what to do next".
[20:04:33] <GothAlice> (Such as checking a document version number and calculating a new atomic operation to "catch up".)
[20:16:40] <tesjo> Is there a db query called offset.Could not find any on doc..But I dont get error when using offset.I am using mongoid
[20:37:57] <pokEarl> do you lose the ordering of documents or something when you do a compressed mongodump?
[20:39:12] <cheeser> no
[20:40:38] <pokEarl> have some script i'm running to generate test data and supposedly it generates the test data into a database, then creates a dump of that test data and uploads it somewhere. When I run tests against the generated database they all pass but when i download the uploaded dump restore it and run against them they fail, but guess its something else weird thats going on then :(
[20:48:42] <pokEarl> does something else change then? just ran tests against a database everything passes, then did manual mongodump, dropped the database and did a mongorestore and now they fail
[20:49:51] <pokEarl> http://pastebin.com/J7y5qfL9 the dump/restore commands
[20:52:18] <pokEarl> ah theres a --maintainInsertionOrder maybe that helps
[21:16:11] <charnel> how can I set created_at to created_at.dd ?