PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Thursday the 25th of August, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[02:43:58] <tomatto> hi, please how can i remove documents if count is over 130 and are old than month?
[02:44:51] <joannac> tomatto: https://docs.mongodb.com/manual/reference/method/db.collection.remove/#remove-all-documents-that-match-a-condition
[02:52:57] <tomatto> joannac: is possible to count documents in query?
[02:53:15] <cheeser> yes.
[02:53:24] <cheeser> db.collection.find({...}).count()
[02:54:06] <tomatto> cheeser: i mean in db.collection.remove({})
[03:32:49] <AvianFlu> tomatto, you should look into capped collections
[03:32:52] <AvianFlu> and maybe ttl indexes too
[03:41:46] <cheeser> tomatto: you mean what now?
[10:37:26] <cppking> hello guys what's the difference of command when create range or hash based sharding collection?
[14:27:31] <cr0mulent> Hello, I would like to query the contents of one collection and insert the results into another collection with an added key value pair. Could someone suggest where I should look in the documentation?
[14:40:57] <StephenLynx> hm
[14:41:10] <StephenLynx> you could use $out on an aggregation
[14:41:12] <StephenLynx> or do it manually.
[14:47:08] <r0j4z0> hi there!
[14:47:25] <r0j4z0> one quick question
[14:47:50] <r0j4z0> i can run two or more copydatabase in parallel?
[14:49:04] <r0j4z0> y need to copy 10 databases from one server to another and i want to do some parallelization, but i cant find any information /documentation about it
[14:51:42] <r0j4z0> both servers are fresh, mongod only takes about 10% of the cpu and both have plenty of ram available
[15:09:11] <roadrunneratwast> hi. i am a software engineer, not a database guy. can someone recommend a tutorial or book that would help me how to think about data design. i do already have some information in a spreadsheet. but i would like to do some sort of analysis on this data before i just dump it in a a table. also: i have no real way to think about sql vs. nosql. sorry this question is so rudimentary
[15:09:33] <GothAlice> roadrunneratwast: Are you familiar with JSON?
[15:09:45] <roadrunneratwast> yeah sure. i am a javascript dev
[15:10:09] <roadrunneratwast> now
[15:10:11] <GothAlice> roadrunneratwast: SQL treats your data like a spreadsheet; in flat tables with rows (records) and columns. All of the SQL "magic" is in combining them in various ways through JOINs.
[15:10:31] <roadrunneratwast> yeah. i have used postgres and mongo
[15:10:40] <roadrunneratwast> and oracle and mysql
[15:10:42] <GothAlice> roadrunneratwast: Document databases like MongoDB store documents, not rows, in collections, not tables. In the MongoDB case, they're like JSON, but with additional types, such as 64-bit accurate integers.
[15:10:48] <roadrunneratwast> right
[15:11:16] <GothAlice> http://www.javaworld.com/article/2088406/enterprise-java/how-to-screw-up-your-mongodb-schema-design.html may be useful as a starting point.
[15:11:24] <roadrunneratwast> ok
[15:11:26] <roadrunneratwast> thanks
[15:13:14] <roadrunneratwast> what i've seen at work is that people make tables which have the columns (eg): NAME, TITLE, DATE, EVERYTHING_ELSE, where everything else is some huge messy json object, i am not saying that nosql encourages such messiness but it makes me concerned about making sure the system is well designed
[15:14:11] <GothAlice> roadrunneratwast: MongoDB has no concept of "tables"; that looks like a misapplication of a relational database, i.e. SQL encourages such messiness.
[15:14:45] <GothAlice> In MongoDB, since your document is effectively just a structured JSON object, there is no need to ever have an "everything else" field. You can always just have more fields.
[15:15:39] <GothAlice> I.e. even within a single collection you can have {name: "Alice"} as one document, and {name: "Bob", knows: ["Alice"]} — i.e. fields that are optional. (There is no particular requirement for every document in a collection to follow the same structure. It's recommended, but optional fields are a thing.)
[15:16:15] <GothAlice> roadrunneratwast: If you are familiar with Entity-Attribute-Value, that is the ultimate attempt by SQL (relational) databases to pretend to be document databases. ;)
[15:17:33] <roadrunneratwast> i think you are a saleswoman
[15:17:42] <roadrunneratwast> you work for the company?
[15:17:49] <roadrunneratwast> it certainly sounds like it
[15:17:58] <GothAlice> ...
[15:33:02] <cr0mulent> Does $out overwrite a collection or will it insert records into an existing collection?
[15:34:28] <cheeser> overwrite
[16:10:30] <cr0mulent> I want to create a query that will take all records from an one collection that match criteria, remove the _id, add a new key value pair then insert that document into another collection. Does this script look like it will work correctly? http://pastebin.com/Etwij9ZX
[16:13:41] <cheeser> looks promising
[16:20:48] <cr0mulent> cheeser: thanks
[16:49:43] <malorie> hi all. I'm trying to add "references" do a document that depend on an array-field of that document. on reference per array-item. but in order to get the required _ids I need to do multiple find()s, and I don't know how to aggregate them, because of the callbacks. any ideas, how to do that?
[16:49:58] <malorie> also, I'm using nodejs
[16:53:23] <StephenLynx> what do you mean you don't know how to aggregate because of callbacks?
[16:55:08] <malorie> well, the result of the find needs to be passed to the callback, right. i.e., I can't return it
[16:55:25] <StephenLynx> no.
[16:55:36] <StephenLynx> it has to be passed to the function that is updating documents.
[16:55:56] <StephenLynx> you just call the update from the find's callback.
[16:56:11] <malorie> so I should update multiple times?
[16:59:20] <StephenLynx> no.
[16:59:24] <StephenLynx> I mean.
[16:59:28] <StephenLynx> yeah, no.
[16:59:38] <StephenLynx> you can use a bulkwrite.
[16:59:49] <StephenLynx> and update each one with the proper values.
[16:59:57] <StephenLynx> one aggregate and one bulkwrite should suffice.
[17:01:56] <malorie> ok, I see
[17:03:31] <malorie> but the operations to bulkwrite depend on the document, still
[17:03:50] <StephenLynx> so?
[17:04:28] <malorie> well, how do I construct the operations without again having the callback issue?
[17:04:46] <StephenLynx> what do you mean?
[17:05:32] <malorie> given the document { parts: [ "bla", "foo", "bar" ] }
[17:06:17] <malorie> I want to add a field "references" where the parts are looked up in another collection
[17:07:07] <StephenLynx> go on
[17:07:33] <malorie> so for each part I need a find(), where the result is only available inside the callback
[17:07:39] <StephenLynx> no, you don't.
[17:08:01] <StephenLynx> aggregate everything you need and then do the bulkwrite.
[17:08:10] <GothAlice> Find all of the values you need, build a bulk update, and execute it to set the references.
[17:08:45] <malorie> how do I find all the values I need, though? :x
[17:08:55] <StephenLynx> with a find or aggregate.
[17:09:09] <StephenLynx> I don't think an aggregate is required, though.
[17:09:12] <GothAlice> When the "with" block is left, the bulk write is executed. self.scalar() runs a find, projecting just the fields requested, in this example.
[17:09:31] <StephenLynx> even though it could make your life easier with a group.
[17:09:33] <GothAlice> (So, it's iterating the result of a find, using it to build the "ancestors" list of reference for each thing in the tree.)
[17:16:16] <malorie> ok. thanks for all the input
[17:16:26] <malorie> I think I can make something off it
[18:27:40] <burgalon> anyone can help with intersection indexes http://stackoverflow.com/questions/39152189/mongodb-query-not-using-intersection-indexes ?
[19:36:07] <Jimu> I've just done csv exports from mongodb using mongoexport.exe and from postgresql using psql.exe of equivalent tables/collections, and postgresql did 40 million records in ~70 seconds, and mongoexport did 23.5 million records in 600 seconds. No query involved in either one.
[19:40:01] <StephenLynx> >.exe
[19:40:14] <StephenLynx> well, is not like you are running on a serious system anyway.
[19:41:20] <StephenLynx> besides, mongo's types are much more complex and each field must specify its own type.
[19:41:35] <StephenLynx> unlike on a RDB where you just tell once how each field is and all rows follow it.
[19:41:48] <StephenLynx> so there is much more work to be done on mongo due to the fact it isn't a rdb.
[19:41:55] <Jimu> so, this is expected performance?
[19:41:59] <StephenLynx> no.
[19:42:13] <StephenLynx> I am just saying in this scenario you can justify a decreased performance.
[19:42:37] <StephenLynx> specially when using export
[19:42:39] <StephenLynx> instead of dump.
[19:42:57] <StephenLynx> with dump it doesn't have to manipulate the data nearly as much.
[19:43:25] <Jimu> Yeah, it's frustrating we're currently stuck using CSV as a data interchange
[19:43:39] <StephenLynx> RIP in pepperoni
[19:43:58] <StephenLynx> what if you write your own exporter?
[19:44:17] <StephenLynx> you might be able to get better performance from a specialized tool.
[19:44:35] <Jimu> Suppose I could...
[19:45:33] <Jimu> What do you think the best current driver is? node? .net?
[19:45:50] <StephenLynx> I don't know.
[19:45:54] <StephenLynx> I have only used node's.
[19:46:04] <StephenLynx> but I can say it is pretty good.
[19:46:25] <n1colas> Hello
[19:46:37] <StephenLynx> you shouldn't pick the runtime environment based on the driver.
[19:46:39] <StephenLynx> IMO
[19:47:32] <cheeser> the best is the java driver
[19:48:37] <Jimu> That's handy if true, that's the language I'd probably have to use
[19:49:02] <StephenLynx> I'd really avoid a java back-end.
[19:49:49] <cheeser> yeah but you avoid anything you didn't write yourself.
[19:49:53] <StephenLynx> its design its too dogmatic and building it is clunky.
[19:49:55] <StephenLynx> that is not true.
[19:50:18] <cheeser> building it is clunky?
[19:50:21] <StephenLynx> yes.
[19:50:24] <cheeser> ok.
[19:53:29] <GothAlice> Pymongo is very similar to interacting in the mongo shell itself.
[19:53:38] <GothAlice> Like cheeser, though, I'm biased towards the solution I use daily.
[19:54:59] <StephenLynx> nothing is as similar than the shell than node's, though.
[19:55:08] <StephenLynx> the syntax barely changes.
[20:00:37] <GothAlice> typeof "string" !== typeof new String("also a string") — disqualifies JS for serious use, for me. ;P
[20:01:00] <GothAlice> (Also the whole 48-bit integer accuracy thing.)
[20:01:13] <GothAlice> Or, rather, 54-bit.
[20:02:00] <StephenLynx> why would you use new String to begin with?
[20:02:22] <StephenLynx> its easy to misuse a language and then say you don't like it.
[20:02:52] <StephenLynx> "what do you mean an unrelated variable changed when I referenced its pointer and fiddled with it? C sux"
[20:03:01] <cheeser> that "string" and new String() have two different types is problematic
[20:03:26] <GothAlice> StephenLynx: Claiming commonly used functionality (the "new" operator) is "misuse" is problematic, too.
[20:04:02] <StephenLynx> using "new String" is not a commonly used funcionality.
[20:04:06] <StephenLynx> no one uses it.
[20:04:17] <GothAlice> http://www.javaworld.com/article/2077150/scripting-jvm-languages/using-javascript-s-built-in-objects.html < except where it's documented as being interchangeable.
[20:04:30] <StephenLynx> >javaworld.com
[20:04:31] <cheeser> no one should, for sure. i see people doing that in java too and it makes wanna pull my hair out.
[20:04:35] <StephenLynx> >reference in javascript
[20:04:40] <StephenLynx> sure thing, m8
[20:04:45] <GothAlice> StephenLynx: Sorry, not sure how pointing out the domain name is an argument.
[20:05:12] <StephenLynx> it is an argument as in that place probably doesn't have enough people with know how of the language.
[20:05:16] <StephenLynx> thus, they misuse it.
[20:05:29] <GothAlice> With no supporting evidence to that effect. A very poor argument.
[20:05:51] <GothAlice> (I.e. you aren't psychic and know not of the people running that site.)
[20:06:02] <StephenLynx> kek
[20:06:21] <GothAlice> [] + [] === ""
[20:06:30] <StephenLynx> misuse.
[20:06:32] <GothAlice> {} + {} === NaN
[20:06:37] <StephenLynx> again, misuse.
[20:06:50] <GothAlice> First, the inconsistency is atrocious, misuse or otherwise.
[20:06:51] <cheeser> agreed. using js is a misuse.
[20:06:59] <StephenLynx> kek
[20:07:30] <cheeser> https://scontent-lga3-1.xx.fbcdn.net/t31.0-8/s960x960/14086287_1272068609493522_6975101222844759949_o.png
[20:07:36] <GothAlice> Second, basic concatenation of arrays is a… fairly fundamental expectation across languages. The operation is trivial: return a new array that is the combination of the two. Failing to meet basic cross-language expectations means you're learning more JS exceptions than rules.
[20:07:44] <GothAlice> Third, cheeser +2
[20:07:48] <StephenLynx> fundamental?
[20:07:53] <StephenLynx> I don't think C have it.
[20:08:05] <StephenLynx> I never expected that in any language I ever used.
[20:08:36] <cheeser> java doesn't support array concat that way, either.
[20:08:48] <cheeser> but java tends not to overload operators overly much.
[20:08:56] <cheeser> numbers and strings primarily
[20:09:35] <StephenLynx> using "+" to concatenate arrays is ludicrous if you ask me, because of typing.
[20:09:58] <GothAlice> "Typing". JavaScript. Sorry, wat?
[20:10:14] <StephenLynx> I didn't mention js.
[20:10:34] <StephenLynx> and you just pointed it to me that + doesn't concatenate arrays in js.
[20:10:50] <GothAlice> Also not sure how strong typing would be a negative impact on this. It'd be a type error to concatenate incompatible arrays, sure.
[20:10:56] <StephenLynx> besides, [] are not arrays, they are lists.
[20:11:00] <Zelest> *yawns*
[20:11:00] <StephenLynx> they are actually objects.
[20:11:21] <StephenLynx> down to what typeof gives you.
[20:11:28] <GothAlice> StephenLynx: Semantic pedantry an argument does not make, either. In fact, being an object, it has no excuse not to implement the operators.
[20:11:37] <GothAlice> "foo" + "bar" == "foobar". Concatenation. It's a reasonable first step to extend that to other types. (Of course, in a number of languages such as JS or Java the expectation is quickly violated, sending the user off to find the "right" way to do it.)
[20:11:38] <StephenLynx> of course it does.
[20:11:41] <StephenLynx> its a bad feature.
[20:12:13] <StephenLynx> and is not semantic pedantry.
[20:12:24] <StephenLynx> there is a very clear difference between arrays and lists.
[20:12:42] <GothAlice> Which doesn't matter for the argument for or against the ability to concatenate either.
[20:13:06] <StephenLynx> well, if you are going to arbitrarily pick which arguments are good or not, I am done then.
[20:15:33] <GothAlice> In a similar "they're so different it doesn't matter" sense, tuples and lists in Python are "different"—very different, in some ways, such as mutability and hashability—but behave consistently when used with standard operators. Are consistency, and principle-of-least-surprise, not desirable goals for a language?
[20:16:49] <StephenLynx> it matters if you are going to claim it's a "commonly expected feature".
[20:17:08] <StephenLynx> a C programmer would never expect it.
[20:26:25] <GothAlice> You are speaking of experienced programmers. I'm talking about the look on the face of a developer who is learning, has just learned string concatenation (in nearly any scripting language), then has their reasonable expectation violated almost instantly. But hey, if obtuse is "reasonable", can't argue with that. Enjoy your JS. ;P
[20:27:19] <StephenLynx> since when bad programmers matter?
[20:27:30] <StephenLynx> get good or get out.
[20:30:38] <StephenLynx> the problem with javascript is that it doesn't conform with the modern idea that programmers should be cushioned. it is concerned about having a intuitive, lean and cohesive core and expects you to keep yourself away from the bad parts.
[20:30:47] <StephenLynx> and many programmers think that's a flaw.
[20:30:59] <StephenLynx> how dare this language not hold my hand?
[20:31:59] <GothAlice> "Learn to adapt to the mistakes of others" — potentially valuable lesson. On the other hand, "get good or get out" — really poor way of stating such. Abusive, even. I get the distinct sense you've never been a tutor or other educator. You are literally arguing _for_ excessive complexity, which is virtually incomprehensible.
[20:32:21] <StephenLynx> excessive complexity? what?
[20:32:22] <Jimu> i love these wonderfully pointless flamewars
[20:32:27] <GothAlice> There is no gain from such complexity, there is only additional headspace requirement.
[20:32:38] <StephenLynx> since when using less features is more complex?
[20:32:41] <Jimu> exit
[20:32:47] <GothAlice> Jimu: Need a / in there.
[20:32:49] <GothAlice> ;)
[20:33:53] <StephenLynx> because this is all that good js is about: not using the bad features. there is even a whole mode (strict) dedicated to make it more lean and strict like C.
[20:34:29] <StephenLynx> without ambiguities, without guessing.
[20:34:35] <StephenLynx> without blank filling.
[20:37:12] <GothAlice> … you've read through the ECMAScript standard, right? The cost of a lack of ambiguity, in many cases, is multiple pages of organically grown decision tree the developer needs to memorize to not shoot themselves in the foot. And that's just the comparison operator. (Oh, right, == is misuse, === for life.)
[20:37:14] <GothAlice> But hey, you like it, I'll leave it at that. I'm sure you have your reasons for liking it and defending it the way you do.
[20:37:50] <StephenLynx> and heres the best thing about js
[20:38:04] <StephenLynx> unlike broken languages, it NEVER broke backward compatibility
[20:38:07] <StephenLynx> unlike lua, python
[20:38:41] <StephenLynx> you dont have to follow said organic decisions.
[20:39:06] <StephenLynx> you can stick to the minimal and just write lean, intuitive code that will work until the end of the times.
[20:40:07] <StephenLynx> and my reason to defend it to just refute FUD.
[20:52:49] <alexi5> Hello everyone
[22:39:35] <MacWinner> is there a simple way to see which indexes have not been used over the last N days?
[22:48:38] <cheeser> nope