PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 10th of May, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:20:50] <Ryzzan> kurushiyama: sensei... how r u?
[00:20:52] <Ryzzan> :)
[00:30:02] <kenalex> hello
[00:34:07] <kenalex> if i have a document like {'a':[{'id':2},{'id':4}],'b':[{'id':2},{'id':21}] } what query can I use to check if the lists refered to by fields 'a' and 'b' are equal ?
[00:38:05] <Boomtime> @kenalex: https://docs.mongodb.com/manual/reference/operator/aggregation/setEquals/
[00:50:53] <kenalex> thanks
[05:45:46] <Keverw> Is Mongo 3.2 limited to one index per query? Was reading a post from 2012 mentioning that, but that's 4 years ago now.
[06:08:28] <kurushiyama> Keverw: As a rule of thumb, this still has its worth. Albeit there are index intersections (https://docs.mongodb.com/manual/core/index-intersection/), I did not find it easy to leverage them.
[06:13:37] <Keverw> @kurushiyama interesting. hmm that's a bit disappointing. I wonder in reality how much of a problem it is... I see the use of querying multiple fields at once.
[06:17:10] <kurushiyama> Keverw: Let me assure you: it is very,very rarely. I have yet to find a situation where this became a problem.
[06:18:03] <kurushiyama> Keverw: Correction: I had it once or twice, when a customer created an insufficient index. Remember: there are compound indices.
[06:18:37] <kurushiyama> Keverw: And said compound indices can be reused for single fields under certain conditions.
[06:21:39] <Keverw> oh compound index sounds interesting.
[06:22:54] <Keverw> @kurushiyama and I guess once collection could have multiple compound indexes? but only use one compound index per query? So say one collection but you wanted to beable to run a few different types of queries against it.
[06:22:55] <kurushiyama> Keverw: It is. Lets say you want to do sth like db.coll.find({foo:"bar",a:"b"}), you'd simply have an index {foo:1,a:1} (order matters)
[06:23:10] <kurushiyama> Keverw: Of course
[06:23:46] <Keverw> @kurushiyama Interesting. I'm starting to think everyone telling me to not use MongoDB just don't understand it or using out dated info.
[06:24:14] <kurushiyama> Keverw: The advantage with the example above is: Even when you only do a query like db.coll.find({foo:"bar"}), the index {foo:1,a:1} is used
[06:24:34] <kurushiyama> Keverw: "just don't understand it or using out dated info." I could not agree more
[06:24:58] <kurushiyama> Keverw: Let's take the infamous "looses data" statement
[06:25:07] <Keverw> @kurushiyama Oh nice. :) I think mongo is cool because it's scale options, and I kinda hated writing SQL and converting code back and forth.
[06:25:53] <Keverw> @kurushiyama but some friends told me it was a bad idea, and even a company I consulted with about their commercial database followed up with me and I told them I was going with Mongo, and said some things that got me rethinking.
[06:26:30] <kurushiyama> Keverw: The people claiming that MongoDB looses data simply did not read the docs. There is a notion of writeConcern, which gives very granular control over when a write is acknowledged
[06:27:45] <Keverw> @kurushiyama Interesting. I think there's a way to default that to write to a few repl. I know I seen some exmaples when they included it with the update statements.
[06:28:34] <Keverw> Plus there's journaling in Wildtriger
[06:29:10] <kurushiyama> Keverw: There was a rather unfortunate decision (in hindsight) that the _default_ writeConcern used to be 0, basically saying "acknowledge that the write reached the server only". With a default writeConcern nowadays, this is different. And if people would have read the docs, it would have been different before.
[06:29:30] <kurushiyama> Keverw: journaling was there with MMAPv1, too.
[06:30:03] <kurushiyama> Keverw: And it is wiredTiger ;)
[06:30:51] <Keverw> @kurushiyama Oh cool. I was assuming that was new.
[06:31:23] <kurushiyama> Keverw: Bottom line: You have more granular control (configurable in general and per write operation) over durability than with any other DBMS I have met.
[06:32:21] <Keverw> @kurushiyama Cool :) You into Node.js and Mongoose by any chance?
[06:32:47] <kurushiyama> Keverw: Do not use Mongoose. Imho, it has severe conceptual problems.
[06:33:08] <kurushiyama> Keverw: Use the raw driver instead.
[06:33:38] <Keverw> @kurushiyama Oh... I started using it. :/
[06:34:29] <kurushiyama> Keverw: And let me guess: You did what you used to do with RDBMS: You started with identifying your entities, their properties and relations and modelled accordingly?
[06:34:45] <Keverw> @kurushiyama I was wondering though. It mentions shardkey in it's schemas but I couldn't find where to set it for the native driver. So that's what I was about to ask about.
[06:34:54] <Keverw> Yep
[06:35:07] <kurushiyama> Keverw: And this is where the problems start.
[06:35:54] <kurushiyama> Keverw: One of the major advantages of MongoDB is that you can model your data und the according queries optimized for your use cases.
[06:36:16] <Keverw> @kurushiyama hmm interesting. I figured it'd help stay organized and prevent typos of field names.
[06:36:39] <kurushiyama> Keverw: To leverage this advantage, however, you need to approach modelling differently
[06:37:56] <kurushiyama> Keverw: SQL way: Identify entities, properties, relationships, bang your head against the wall for some time to get upper left above and beyond JOINS right to get the questions answered you have to your data to cover the use cases.
[06:38:54] <kurushiyama> Keverw: MongoDB: Identify your use cases, derive the questions you have on your data for them, create optimized model to answer those questions.
[06:40:11] <Keverw> @kurushiyama hmm. other than that, anything else wrong with Mongoose? There was some other additions it had I liked, but I could always emulate them if I wanted with some custom functions.
[06:40:50] <kurushiyama> Keverw: With optimizations made for the most common use cases. I have to admit that this sometimes means that you have to take performance "penalties" for less common use cases, or accept redundancy (not a bad thing in MongoDB).
[06:41:44] <kurushiyama> Keverw: Other than that, if you model properly, Mongoose is not much more than an additional moving part, introducing an additional layer in your app eating performance.
[06:42:34] <kurushiyama> Keverw: Let us take .populate() for example. You are aware of its working?
[06:42:52] <Keverw> @kurushiyama Yeah. I've heard of it and plan to use it.
[06:42:59] <kurushiyama> Keverw: Dont!
[06:43:45] <Keverw> @kurushiyama or planned haha. Didn't know there was any bad in using it...
[06:44:01] <kurushiyama> Keverw: That is _exactly_ the point. It emulates JOINS. What they do not tell you is that these are client side JOINS, inherently using rather inefficient queries.
[06:44:38] <kurushiyama> Keverw: Let me give you an example.
[06:45:35] <kurushiyama> Keverw: Let's say you have users and posts. user {_id:someId, name:"Keverw"...}
[06:46:12] <kurushiyama> Keverw: Now, you have a use case in which you want to display the last 10 posts made by any user on a page
[06:47:17] <kurushiyama> Keverw: Of course, we could model a post like {_id:someId, user: userId, text:"foo"} and leverage Mongoose's populate to get the user names.
[06:48:56] <kurushiyama> Keverw: But lets say we only want to display the user names together with the posts. We can model our posts like {_id:someId, user:"Keverw", text:"foo"} and reduced the use case to a single query.
[06:49:20] <kurushiyama> (dates or sth set aside for the moment)
[06:52:20] <Keverw> Interesting. I really liked the idea of storing names or picture urls once. Updating thousands or even millions of records sounds wasteful compared to just a ID. but hmm. That would probably get tricker when checking if a user is suspended or not, etc
[06:53:54] <kurushiyama> Keverw: That example was heavily simplified for the sake of making it easy to grasp.
[06:54:57] <kurushiyama> Keverw: But what you should understand is that we optimized for a quite common use case (displaying posts) vs a rather uncommon one (changing of a username).
[06:56:14] <kurushiyama> Keverw: Oh, and btw, updating the username of a user in all posts would be a single query: db.posts.update({user:"Keverw"},{$set:{user:"KeverwMongoMonger"}})
[06:57:05] <kurushiyama> Keverw: And there are even ways to optimize this.
[07:00:00] <Keverw> @kurushiyama hmm interesting. What about profile pictures? hmm. I guess I was always taught to store something once but I guess that's not always the case with Mongo then.
[07:01:20] <kurushiyama> Keverw: Many ways to do it. What I would do is have a fixed url: http://my.app/profiles/<username>/profile.jpg
[07:01:43] <kurushiyama> Keverw: No data to be stored, just a convention to be met.
[07:02:37] <Keverw> @kurushiyama hmm didn't think of that :)
[07:03:44] <kurushiyama> Keverw: If all you take out of this conversation is that one should model optimized for the most common use cases, that'd be great.
[07:04:33] <Keverw> @kurushiyama at least most things are post specific. things like friends probably not a good idea to store in every post but hmm. Even for some PHP projects i've done joins in PHP as I really hated writing joins. I'd just make to where WHERE IN instead of doing a loop to get multiple items with the same ID in the array.
[07:06:04] <Keverw> @kurushiyama Yeah. You surely do have me thinking a bit differently on how to approach things.
[07:16:25] <Keverw> @kurushiyama With the native driver, do you need to include the shardkey when doing queries, adding or updating content? I know Mongoose mentions it, but say you were mixing both drivers, or say later on you shareded and not apps restarted yet... I wonder if anything odd would happen with the queries not including the key. I think all it would do is hit all shards, so a bit slower but wouldn't break.
[07:18:33] <kurushiyama> Keverw: Do you want to shard right away?
[07:19:08] <Keverw> @kurushiyama Considered doing it right away, also later. I was thinking maybe later.
[07:19:53] <kurushiyama> Keverw: In general, you never _need_ to include the shard key in your query. But you definetly _should_.
[07:20:34] <kurushiyama> Keverw: Picking a proper shard key for your use case can be quite tricky and needs careful consideration.
[07:20:45] <Keverw> @kurushiyama Oh I see. so just for optimizations. and I think you need them for queries only, not inserting new content?
[07:21:45] <Keverw> @kurushiyama Yeah. Probably shouldn't worry about it right away but as the user base increases I'll need to study on picking them but I think it should be fairy trivial to migrate.
[07:23:19] <kurushiyama> Keverw: Say you shard on the default _id, but hashed, and you use objectIds. In this case, you would not need to include the shardKey. If you omit the shard key, it evaluates to null and the resulting doc will be stored on the according shard (the one assigned $minKey, iirc)
[07:25:01] <Keverw> @kurushiyama Interesting. I had a feeling most cases would shard on the id probably but hmm
[07:26:24] <kurushiyama> Keverw: I am not too sure. Say you want a shard per region (EMEA, NCSA, APAC), then it might be reasonable to already include those reagions and use them as a shard key later. But choosing a shard key is probably one of the most difficult things to do in MongoDB, because there are so many factors to be taken into account
[07:26:35] <Keverw> @kurushiyama I guess as with everything, once I gain more experience with this I'll be moving a lot faster than I have been so far.
[08:38:55] <jokke> hey
[08:40:22] <jokke> i have time series data with a timestamp in _id. Each doc has an attribute panel_id. I need to query the last docs (by timestamp) for a specified panel_id. I'm quite clueless on how to do this.
[08:40:49] <jokke> this won't work because memory limits get exceeded: https://p.jreinert.com/1NL/javascript
[08:42:05] <jokke> i'm thinking about storing the last samples in a separate collection
[08:42:17] <jokke> the query just takes way too long
[08:42:27] <jokke> or would take, if it worked
[11:51:12] <jlambert121> on a clean centos 7 box with all updates, mongodb 3.2.6-1.el7 starting mongo I get selinux errors (http://pastebin.com/Xb6QPCUB). setenforce 0 allows mongo to run correctly so i think the issue is just selinux. google hasn't been helpful in finding a solution to this, has anyone else had this issue?
[11:56:15] <Rumbles> j #apache-spark
[11:56:21] <Rumbles> gah
[11:56:25] <Rumbles> :(
[12:53:55] <Zelest> Derick, I've installed the new MongoDB client and try to $m = new MongoDB\Client('...'); and I get the error that class MongoDB\Client doesn't exist.. o_O
[12:54:13] <Zelest> Derick, php -m does list mongodb as a compiled module.. so where do I fail?
[12:59:34] <kurushiyama> Zelest: You sure about the backslash? I am not exactly an expert on PHP, but that looks strange to me.
[13:00:58] <Zelest> kurushiyama, That's what namespace to use (if I know my php correctly), neither MongoClient, MongoDB or Mongo works either though :S
[13:12:06] <Zelest> Hmms, mayhaps I don't have everything I should... *confused*
[13:12:33] <Zelest> Derick, I've installed the pecl-mongodb driver (1.1.6) .. is there anything else I need to install?
[13:25:19] <Zelest> Aah, nvm :D
[13:25:48] <kurushiyama> Zelest: Share your enlightened moment! ;)
[13:25:52] <Zelest> Hold!
[13:25:56] <Zelest> Verifying its working :)
[13:28:02] <Zelest> Now I get it.. the mongodb driver is just a very high-level framework to do magic mongodb stuff.. Then you use a php-written library on top of that, like https://github.com/mongodb/mongo-php-library
[13:28:22] <Zelest> the later which one would install using composer
[13:30:40] <Zelest> :D
[14:06:31] <Derick> Zelest: \MongoDB\Client is part of the PHP library, which you need to fetch through composer
[14:11:32] <Zelest> Derick, Yeah, thanks.. sorted it all out :D
[14:13:13] <Zelest> Derick, anything new I need to know regarding the replicaset features in the new mongodb driver? E.g, automagic failover and such..
[14:33:09] <Derick> Zelest: should all be automatic like it used to work
[14:49:59] <Ben_1> what's the difference between _id: "test" and _id: ObjectId("test") ?
[14:50:54] <kurushiyama> Ben_1: the former is a string, the latter is an invalid objectid
[14:52:15] <kurushiyama> Ben_1: both are valid _id's, though
[14:52:42] <Ben_1> but the string is not good to search for ?
[14:53:00] <kurushiyama> Well, at least it is valid ;)
[14:53:11] <Ben_1> that's not the point :P
[14:53:32] <kurushiyama> Both are indexed (_id is indexed by default), so both can be searched for efficiently
[14:53:38] <Ben_1> it has no benefit for me when it's valid but 200 times slower
[14:54:05] <Ben_1> ok so ObjectId is just for better readability
[14:54:17] <kurushiyama> No
[14:54:28] <kurushiyama> ObjectId is a type
[14:54:32] <kurushiyama> like string
[14:54:33] <cheeser> ObjectId("test") will fail
[14:54:34] <kurushiyama> int
[14:54:38] <kurushiyama> float
[14:54:58] <Ben_1> cheeser: I know it was just an example
[14:55:07] <Ben_1> ObjectId has to be a hex value
[14:55:25] <Ben_1> Ah ok it's a type. Ok Thanks :)
[14:55:27] <kurushiyama> Ben_1: https://docs.mongodb.com/manual/reference/method/ObjectId/#description
[14:55:51] <cheeser> i think it's a bson type even
[14:57:20] <kurushiyama> cheeser: Nope
[14:57:27] <cheeser> no? hrm.
[14:57:30] <cheeser> oh, well. :)
[14:57:58] <kurushiyama> cheeser: Sorry, was wrong
[14:58:02] <kurushiyama> cheeser: It is.
[14:58:20] <cheeser> i was pretty sure... to lazy/busy to actually look it up, though. ;)
[14:58:31] <kurushiyama> cheeser: type 7
[14:59:04] <kurushiyama> cheeser: or x07, to be precise.
[15:02:14] <kurushiyama> cheeser: Although I can not really see _why_ ObjectId is a bson type...
[15:03:48] <cheeser> because mongodb makes heavy use of it?
[15:05:08] <Zelest> Derick, sweet, thanks :D
[15:05:58] <kurushiyama> cheeser: Well, I see that. But if we assume that BSON is supposed to be a data representation independent of MongoDB... ;)
[17:48:58] <diogogmt> i’m trying to follow the steps in this article to create the first user with authentication enable using the LocalHostException but it doesn’t seem to work: https://docs.mongodb.com/v2.6/tutorial/enable-authentication-without-bypass/
[17:49:15] <diogogmt> i keep getting the message: “Error: couldn't add user: not authorized on admin to execute command”
[17:51:15] <diogogmt> this lines says: “After you enable authentication, only the user administrator can connect to the MongoDB instance. The user administrator must log in and grant further access to the instance by creating additional users.”
[17:51:41] <diogogmt> i’m connecting to the mongo shell without specifying a user, do i need to specify the admin user? what about its password?
[18:40:20] <wspider> for a node app, should I create one connection to mongodb and pass it as parameter to all the functions users will use?
[18:42:22] <wspider> nvm, already figured it out
[18:42:45] <wspider> not really, just found the answer in google, you create one connection object and reuse it through the entire app
[19:14:35] <StephenLynx> wspider, yes. the mongodb driver manages its own connection pool
[19:19:54] <tozz> When using $unset on a couple of nested objects the result is actually that the entire parent tree is removed too. "$unset": { "obj.level1.level2.level3": "" }, The resulting document has obj.level1 deleted, is this expected?
[19:27:20] <tozz> Nevermind, it was something unrelated -_-
[21:06:48] <deathanchor> how can I tell which storageEngine is used for a db in 3.2?
[21:06:54] <deathanchor> is there a command?
[21:10:31] <Derick> deathanchor: for a server: db.serverStatus().storageEngine;
[21:11:24] <Derick> or
[21:11:28] <Derick> db.runCommand( { serverStatus: 1 } ).storageEngine;
[21:13:18] <deathanchor> thx
[21:13:23] <deathanchor> I'm doing some funky fun stuff
[22:55:47] <ayee> I'm trying to deploy ops manager. It worked initially, though after I added my cert through the webui, it no longer works.
[22:56:14] <ayee> The pem format is unclear to me, is it private key, domain cert, chain certs (arbitrary in length) all in the same file separated by line breaks?
[22:56:50] <ayee> I can't figure out how to turn off ssl now that I turned it on in the webui.
[22:57:00] <ayee> I can't find my ssl file name anywhere in /opt using grep. or in /etc
[23:12:26] <ayee> ok, I can talk to the server with the webui now. though my cert is invalid.
[23:12:55] <ayee> Hmm, I've configured apache/nginx many times, but the certs and private key are always in separate files. it's non-standard to mix the certs and private key into an ascii pem file.
[23:13:16] <kurushiyama> ayee: That is not true.
[23:13:44] <kurushiyama> ayee: And as far as I know, a PEM is a cert and the public key.
[23:15:06] <kurushiyama> ayee: Oh, actaully you can have any combination
[23:15:23] <ayee> really?
[23:15:46] <ayee> I tested these certs with nginx on the hello world page, and it works fine with a separate pem (with 3 certs in it), and different file for the key
[23:15:56] <ayee> but if I combine those into one file.. it's invalid in mongodb ops manager