[01:45:50] <smoke_> hi guys im migrating from mysql to mongo db, and was wondering on my website for user auth should i have a seperate user database for mongo or should i have the user credentials included in the main db?
[02:19:33] <morenoh149> how do I insert an array of json objects into a collection?
[02:19:52] <morenoh149> I have [{foo: foo},{bar: bar}]
[02:20:02] <morenoh149> I want them both to be in collecion foo
[02:20:30] <morenoh149> not one document with an array but two doucments
[02:51:57] <dimon222> morenoh149, you have to iterate through them and do insert element-by-element or collect a set of insert statements and execute bulk set
[04:49:48] <morenoh149> okay got it. I feel like it shouldn't be order dependent though. are the other clauses order dependent? say call group then match
[04:51:35] <joannac> no, but they'll get rewritten if possible and if it's more efficient to do so
[04:53:06] <Boomtime> morenoh149: you think that "limit 20 then skip 10" should do the same thing as "skip 10 then limit 20" ?
[04:55:02] <Boomtime> regarding group/match, if i group and create a count field, then match on that count field, how could the order of those operations not matter?
[04:57:47] <cba321> I ll add a new elmt to an existing set
[04:58:13] <joannac> cba321: setOnInsert only applies when the upsert resolved to an insert
[04:58:31] <joannac> if it's an insert, the document does not exist yet
[04:59:37] <cba321> if it doesnt match then I upsert, and insert a new document with in that "event" field a set containing the new elmt and another old elmt
[04:59:56] <cba321> i dont know if thats clear enough :/
[05:08:04] <morenoh149> Boomtime: I think it'd totally be okay if mongodb didn't care in what order the clauses were provided in. The aggregate pipeline could always do match>group>skip>limit. As long as it was documented. Though the existing approach works too.
[05:09:07] <morenoh149> cba321: is there anyway to just get the new Items to be added to the array? would make the mongodb queries simpler
[05:10:30] <Boomtime> morenoh149: do you think that the instructions "limit 20 then skip 10" is the same set of instructions as "skip 10 then limit 20" ? because i think they are radically different
[05:11:13] <morenoh149> Boomtime: yes they are different if order matters. I originally thought the order didn't matter and that skips always execute before limits.
[05:12:03] <Boomtime> my point here is that order matters in the intention
[05:12:11] <Boomtime> it has nothing to do with mongodb
[05:32:55] <Boomtime> cba321: if that solution works for you, that is excellent news
[05:33:03] <Boomtime> morenoh149: i would expect so, yes
[05:59:16] <chanced> i'm running into some weird behavior with $near; it doesn't matter what I set the $maxDistance too I'm not seeing results which should be included
[07:30:27] <Boomtime> you cannot split this error, changing the value of either field would fix the error - even if you kept the value of the other field
[07:48:34] <chovy> turns out i don't really need this composite index. its causing more problems than it solves.
[07:48:43] <chovy> i am just going to require unique names.
[07:50:27] <Boomtime> yep, complex features exhibit complex behavior, keep it simple
[07:54:32] <morenoh149> any help here? https://gist.github.com/morenoh149/06a93947799017822a22
[07:56:55] <Boomtime> morenoh149: group on the combination of city & state, sum the pop
[07:58:46] <morenoh149> Boomtime: you use key for that? http://docs.mongodb.org/manual/reference/command/group/#group-by-two-fields
[08:00:11] <Boomtime> morenoh149: you may be able to do it that way, i'm actually not sure, but i would use the aggregation pipeline since it's a single stage: http://docs.mongodb.org/manual/reference/operator/aggregation/group/#pipe._S_group
[08:06:59] <morenoh149> Boomtime: does that look right? https://gist.github.com/morenoh149/06a93947799017822a22
[08:07:35] <Boomtime> at a glance, looks about right.. does it work?
[08:07:59] <Boomtime> (sorry, i don't have much time now)
[08:08:01] <morenoh149> I need to first filter out cities with less than 25K people
[08:08:14] <morenoh149> it's okay I work through it on my own bit by bit
[08:08:33] <Boomtime> that's actually the best way with aggregation, slowly build up the pipeline you need bit by bit
[08:14:11] <morenoh149> so I have a row per state per city. How do I calculate the average population per city,state key?
[08:16:05] <morenoh149> err average population in the whole set rather
[08:59:23] <aaearon> http://pastebin.com/MmzarjtK how could i insert a field for each sub array inside of the documents 'codes' array?
[09:20:22] <morenoh149> aaearon: so say adding foo into codes[0]? so codes[0].foo != undefined
[09:20:58] <aaearon> foo into all codes' sub arrays
[09:24:17] <aaearon> db.test.update({'orientationId': 79}, {$set: {"codes.$.invalid": false}}, {multi: true}) is what I would think, but i 'Cannot apply the positional operator without a corresponding query field containing an array.'
[10:11:47] <Constg> Hello there, do you know if to use Read preferrences on Secodary preffered (PHP Client), the secondary needs to have slaveOk = true?
[10:48:18] <Bringi_> here you go with your shitty database http://www.heise.de/newsticker/meldung/Studenten-entdecken-Tausende-offene-Firmen-Datenbanken-im-Internet-2545183.html
[11:55:55] <fhain> as always said: idiots should not be in charge for databases
[11:56:08] <fhain> and obviously there are > 40.000 tards doing MongoDB work
[11:56:13] <andrer> fhain: Yeah, baby, talk dirty to me
[11:56:21] <andrer> fhain: I love it when it dirtytalk in bed.
[11:57:54] <fhain> obviously the MongoDB scum does not know the difference between localhost and public IP ...but that's typcial for this overhyped database garbage
[12:39:32] <StephenLynx> they go out of their way to shit talk on the subject
[12:39:37] <StephenLynx> not saying you are not free
[12:39:47] <StephenLynx> you can talk w/e you want about anything
[12:39:55] <StephenLynx> but you put so much energy on it.
[12:40:19] <StephenLynx> first of all, any tech has it flaws. people didnt ditched openssl because of heartbleed
[12:40:24] <StephenLynx> or shell because of shellshock
[12:41:44] <StephenLynx> and if mongodb is so shitty and useless, you are free to use other dbs, no one is trying to convince you of anything here, no one invited you.
[12:45:30] <StephenLynx> google'd it, found out is trending on twitter.
[12:46:08] <StephenLynx> http://blog.schmichael.com/2011/11/05/failing-with-mongodb/ and http://seancribbs.com/tech/2011/11/07/mongodb-and-riak-in-context-and-an-apology/ reading both right now.
[12:54:27] <kexmex> However, a common setup and scalable solution for most Internet services is to have a database server running on one physical machine, while the services using this database service are (often virtualized) running on another machine. In this case, the easiest solution is to comment out the flag ≪ bind ip = 127.0.0.1≫ or to remove it completely2, which defaults to accepting all network connections to the database.
[14:26:12] <fhain> Only retarded idiots use MongoDB
[14:44:22] <jerev> When I run this find query through mongolab, I get results. But when I run the exact same, hardcoded, query through mongojs db.collection.find, I don't get any. -- Any idea what the reason could be? https://gist.github.com/anonymous/47cf8de9888dd77f70d6
[14:45:22] <cheeser> by mongojs you mean the shell?
[15:11:07] <fhain> mongodb: insecure by default - what a design feature
[15:31:53] <chanced> is there anyway to get around the 100 record limit on 2d indexed searches? I'm attempting to sort by a different field but the $near filter is interfering with the sort
[15:35:31] <chanced> "The result set contains at most 100 documents."
[15:36:48] <cheeser> maybe geonear instead? with a 2dsphere index?
[15:36:55] <Constg> Hello there, do you know if to use Read preferrences on Secodary preffered (PHP Client), the secondary needs to have slaveOk = true?
[15:37:18] <cheeser> you set that on the connection
[15:38:17] <chanced> yea, thats what i was afraid of. thanks man
[15:41:10] <cheeser> that's just a guess. the geo stuff is a bit of a foggy area for me.
[15:43:03] <chanced> cheeser: understood; same goes for me
[15:43:14] <chanced> cant tell you how long i banged my head against the wall trying to figure out wtf records were missing
[16:30:25] <kazimir> Hi, can someone advise the best technique for master-master replication? I know that it's currently not supported in Mongo, however I believe there are some application level solutions to achieve this. Can someone maybe share experience/opinion? So far I was able ti find https://pypi.python.org/pypi/MongoMultiMaster , but haven't tested yet. Also, are there any plans to implement multi-master replica soon? Thanks
[16:34:57] <cheeser> best technique advice is to upgrade to something modern and use replica sets
[16:35:12] <fhain> if you want multi-master then use a different DB
[16:36:04] <fhain> use Cassandra or Crate.io when you are looking for real distributed databases instead of the MongoDB toy
[16:37:11] <fhain> Replica sets are a very poor replacement in a distributed environment and an indicator that the mongodb devs can't do better just easy
[16:37:19] <fhain> the mongodb replication story is a flaw
[16:37:54] <andrer> I don't think it is fair to say that fhain has opinions, that's an insult to all other opinions.
[16:37:59] <fhain> and the opinion of many people working with real distributed databases
[16:38:56] <kazimir> before we run into some sort of flame, I'm being a little bit limited with the database I can use in the current solution (opensips). I can use Cassandra indeed, but I was gonna give a change to Mongo as I like the speed and everything. Plus I'm lazy to re-code everythin ;).
[16:39:10] <StephenLynx> fhain is buttmad because some people scanned for mongo servers and they considered they were all vulnerable because you can fuck up and set them in a way they become vulnerable, despite the default settings making them secure :^) I just put him on ignore
[16:39:23] <andrer> fhain: I'm fairly certain that you were one of these people who exposed their MongoDB to the internets, got burnt by it, and you are now fired from whatever job you had, am I correct?
[16:40:11] <fhain> replica sets don't make a distributed database
[16:40:33] <GothAlice> One wonders why people come to a support channel merely to complain instead of writing Yet Another Misguided Blog Post™. Especially when it's actually PEBKAC in 99% of cases.
[16:45:19] <andrer> Fairly certain that's the triggerpoint indeed :D
[16:45:24] <kazimir> anyway if someone has some good thouthgs about the multi-master in mongo, let me know :)
[16:45:37] <GothAlice> kazimir: Alas, multi-master isn't a thing.
[16:46:02] <kazimir> GothAlice: can you elaborate, please?
[16:46:13] <GothAlice> Coordination in a setup like that is not easy, and would add even more latency than simply having one primary further away from your application.
[16:47:39] <StephenLynx> why hes leaving and joining?
[16:47:44] <fhain> the dumbass is you, GothAlice , incompetent MongoDB scum
[16:48:01] <cheeser> let's just pretend she doesn't exist and move on with our lives.
[16:49:48] <GothAlice> kazimir: What use-case do you have that is making you think you need multi-master?
[16:51:04] <kazimir> GothAlice: geo redundant SIP proxy and reading/writing to it's own mongodb
[16:51:19] <kazimir> SIP proxies I should have said
[16:52:56] <GothAlice> kazimir: Considering a new primary will be elected (pretty quickly) in the event of a failure of the "current" primary, the question remains, why multiple masters? There should probably be a single canonical version (primary) which the individual regions update from, no?
[16:56:13] <fhain> "Why multiple masters" is the standard reply because these idiots can not deal with multi master, just easy
[16:58:23] <chanced> damnit, there has to be a way to get a 2d $near sorted.. i really dont want to change this freaking index
[16:58:33] <andrer> fhain: Are you looking for a new job? We have a opening here for people with experience with Cassandra
[17:00:04] <GothAlice> kazimir: I use MongoDB as distributed queue and storage for intra-host messaging on a 200+ VM cluster on one hand, for several dozen smaller applications on the other hand, and on the gripping hand also store 26+ TiB of structured (and BLOB) data using it. None of these uses has ever needed or even desired multi-master.
[17:02:00] <kazimir> GothAlice: thanks. I certainly need to rethink the design and see what I can achieve with the opensips mongo driver. I had some problems with connecting to replicaset and always had to connect to primary server directly only. I might have done some mistakes in the opensips configuration, but will need to double check what is possible whith that driver and what not.
[17:03:23] <chanced> if I pass in the sort to find rather than appending a call to sort on find, will it change the order of operations?
[17:04:12] <GothAlice> chanced: It shouldn't. Until you actually iterate across the cursor, AFIK, you're only "building up" the properties on it anyway.
[17:04:33] <chanced> yea, that's what I was thinking
[17:04:43] <chanced> FML, there has to be a way around this damn 100 record limit BS
[17:10:53] <StephenLynx> I know that joke came from 4chan, but I wonder exactly how, since the FSF doesn't condone it and RMS doesn't use it.
[17:13:12] <GothAlice> StephenLynx: On that cluster I mentioned earlier a kernel compile from depclean takes < 50 seconds. :3 I love integrated distcc support.
[17:20:28] <RoyK> anyone that knows centos7 repos with mongodb supporting ssl?
[17:20:42] <RoyK> (no, I didn't choose that this thing should be running centos)
[17:21:56] <thejav> a few days ago i experienced some outage related to mongodb, where it looked like an indexed query, which is run hundreds of times per second in a collection with millions of documents, was suddenly not using an index. I have the profile records which confirm that it was doing a full scan.
[17:23:13] <chanced> 2dSphere + $near worked somehow
[17:23:26] <thejav> This started happening about a day after I created a new index on this collection. When mongo got in this state, it was thrashing hard enough that I had to restart it. About a day later it happened again, so as a stab in the dark I dropped the new index, and the problem hasn't happened since.
[17:23:41] <GothAlice> RoyK: http://www.dagolden.com/index.php/1711/how-to-build-mongodb-with-ssl-for-linux/ may be old. AFIK SSL is only compiled into the Enterprise official binaries.
[17:24:07] <thejav> I'm trying to figure out why this happened. Has anyone seen anything like this before?
[17:25:33] <GothAlice> thejav: MongoDB may ignore an index for a variety of reasons. Evaluating if the index would be helpful or not may have taken too long, it may have (mistakenly) assumed using the index on that query would have actually taken longer, etc. On critical code paths I always hint indexes to try to reduce the likelihood of index misuse.
[17:26:39] <thejav> GothAlice: thanks. can you point to any documentation around why an index might suddenly get ignored?
[17:28:44] <RoyK> GothAlice: yeah, perhaps setting up a repo too ...
[17:31:52] <thejav> GothAlice: thanks for the link. Currently I feel this collection is in a state where adding an index will break things again. Is it the case that for sufficiently large collections, index hints are required to avoid this weird behaviour?
[17:32:46] <GothAlice> thejav: I found it was more an issue of upgrading MongoDB versions changing the planner enough to switch or stop using indexes. The link I gave does mention situations where cached plans are thrown out, however, and things can change when that happens.
[17:33:32] <GothAlice> Adding an index in the foreground would certainly interrupt operation, however can you not create indexes in the background? (This requires a lot more RAM and a huge amount of time on large collections, but it won't lock the collection.)
[17:35:51] <thejav> GothAlice: I'm definitely creating indexes in the background. When I did this last, the issue happened about a day later, and then again about a day after restarting mongo. What I meant was, if I add any indexes in the future, I feel like this will start happening again.
[17:38:56] <GothAlice> Index creation certainly invalidates existing query plans.
[17:39:11] <GothAlice> Hinting is the single best way to ensure reliable use.
[17:39:59] <chanced> lol, i just saw this: "$near always returns the documents sorted by distance. Any other sort order requires to sort the documents in memory, which can be inefficient. To return results in a different sort order, use the $geoWithin operator and the sort() method. "
[17:40:04] <chanced> god i wish I had seen that earlier
[17:46:07] <thejav> GothAlice: this collection is particularly active (thousands of new records per day), so as the page you linked to says, our query plans are getting re-evaluated all the time, previously without issue. It seems a bit silly to need to hint all queries going forward.
[18:17:44] <Hypfer> hi, I'd like to write something that constantly monitors my flats power usage, temperature etc. Basically at least 5 sensors posting data every 10(subject to change) seconds
[18:17:52] <Hypfer> is it a good idea to use mongo as the data storage?
[18:18:56] <Hypfer> how quick will the disk usage grow? will it use lots of cpu time/disk space? any way to compress old values to save space?
[18:21:05] <cheeser> growth rates can vary based on your document sizes but you can lower that volatility by enabling power of 2 sizing. http://docs.mongodb.org/manual/reference/command/collMod/#usePowerOf2Sizes
[18:22:24] <thejav> GothAlice: for the record, I'm pretty sure this was happening: https://jira.mongodb.org/browse/SERVER-14961 The new index I created was on a field that the query sorted by, and occasionally the query plan chose that (very wrong) query plan, which resulted in a (nearly) full scan.
[18:22:28] <Hypfer> so, cheeser would you say that mongo is suitable for this kind of application or would I be better off looking at different types of databases?
[18:24:45] <GothAlice> Hypfer: There are a number of techniques available to reduce overhead and/or efficiently query. Because MongoDB stores the keys with the values in every single document, I use single-character keys to effectively eliminate that overhead. (Still takes 7 bytes per field, but eh, can't make it more efficient than that.) At work we pre-aggregate our statistics.
[18:25:27] <GothAlice> http://www.devsmash.com/blog/mongodb-ad-hoc-analytics-aggregation-framework is an excellent article on the subject of efficiently storing and querying sensor buoy data.
[18:25:36] <GothAlice> (It includes benchmarks, too.)
[18:26:39] <Hypfer> GothAlice: is there a list with tweaks like those (or would you mind quickly writing one)?
[18:27:14] <GothAlice> Hypfer: For sensor data, the link I gave should cover most aspects other than minimizing key length.
[18:43:22] <jthomas_> Anyone able to help me with a MongoDB 2.4 setup on Debian 7? I'm trying to set up multiple instances for testing purposes only, and I have the server started (mongod -f /etc/mongodb/clientname --fork) but I cannot for the life of me find info on how to connect with the 'localhost exception' that seems to be thrown around like it's obvious
[18:44:07] <cheeser> jthomas_: you can't connect at all?
[18:44:20] <jthomas_> I can't find INFO on HOW to connect!!!
[18:44:21] <thejav> the odd part is: this did happen on 2.6.4, and by chance, when I had to restart mongo, it was upgraded to 2.6.6, and I saw the issue *again* on that version. might be able to reproduce now with this info though.
[18:44:37] <jthomas_> define the port or the instance?
[18:44:47] <jthomas_> that's great to know, which it was in the docs
[18:45:04] <cheeser> unless you pass those to mongod, mongo doesnt' need them
[18:45:39] <GothAlice> jthomas_: Like it is over here? http://docs.mongodb.org/manual/tutorial/getting-started-with-the-mongo-shell/
[18:45:42] <jthomas_> i'm expecting a multi-instance setup, so they're defined in the conf file and are being passed to mongod
[18:46:10] <GothAlice> And elaborated on here: http://docs.mongodb.org/manual/reference/mongo-shell/
[18:46:25] <jthomas_> GothAlice thanks, that's for client stuff which makes sense, but there is nothing like this in the Admin section which is needed before any client stuff should even be mentioned. Thanks for the link!
[18:46:41] <GothAlice> jthomas_: Are your "instances" virtual machines, or merely a cloud of mongod processes running under one kernel?
[18:47:00] <jthomas_> multiple proceeses on one system, one kernel
[18:47:08] <GothAlice> Cool, then yes, you'll need to specify a port.
[18:47:39] <jthomas_> so maybe i'm misunderstanding a lot more; the link GothAlice sent shows how to select a DB but my understanding was that each DB had it's own conf file
[18:47:45] <GothAlice> If you're faking a replica set with sharding, then you actually won't need to mess with port numbers. Your query router should Just Work™.
[18:47:53] <cheeser> each db does not have it's own config file
[18:47:57] <GothAlice> jthomas_: No, MongoDB itself has one config.
[18:48:21] <GothAlice> You also run multiple "databases" under one mongod process.
[18:48:22] <cheeser> each mongod has its own config file. one mongod can serve many different DBs
[18:52:29] <StephenLynx> it is 3rd party from mongo.
[18:52:32] <jthomas_> it's official for our distro.
[18:52:36] <GothAlice> http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/#packages < MongoDB runs their own "official" Debian repo for MongoDB packages.
[18:52:46] <StephenLynx> they are not maintained by mongo.
[18:53:13] <StephenLynx> it is not different than if I maintained them or crazy billy joe bob down the street.
[18:53:13] <jthomas_> regardless, we need to provide the packages that would be expected form a server that comes with default versions and no ability to upgrade.
[18:53:35] <jthomas_> er, ability to pull from non-distro repos.
[18:54:19] <jthomas_> Ok well we can discuss that all day, in the mean time I would really like to get this working to log in and set up DBs etc since my understanding is way off apparently
[18:54:48] <GothAlice> jthomas_: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/ <- official instructions say add MongoDB's official repo to your set to install.
[18:57:54] <jthomas_> ok so, i no longer need to set up configs for each client, I'll just run the default and start it with the init scripts, yes? So how do I stop those that I had forked already if the docs say to not use 'kill' on it?
[18:58:29] <GothAlice> Since this is first time setup, you probably don't have any data stored that you care about. Nuking it is a-ok in this case.
[18:59:09] <GothAlice> If you care about database segregation, turn on the directory-per-db option, by the way. That'll allow you to mount different partitions and other nifty things on a per-database basis.
[19:00:05] <jthomas_> ok so in the future, how Would I do that without Kill ?
[19:00:54] <GothAlice> kill -HUP says "hangup" to a process, which typically signals that process to reload its configuration files without actually stopping. (I.e. that's how you "reload" your Apache, SSH, or Nginx config.)
[19:01:37] <GothAlice> kill -9 = do not pass go, do not collect $200. The process gets immediately killed by the kernel. A normal "kill" (sending a terminate signal) gives the process time to gracefully shut down, making it perfectly safe to kill your DB processes.
[19:01:38] <jthomas_> is there a tutorial with the basic walkthrough of setting this up and adding DBs and users? the docs seem to link all over to itself without the answers that i need
[19:26:21] <cheeser> replica set min version is 2.2.0 for backup
[19:27:19] <obeardly> hmmm....interesting, I was told directly by MongoDB when they were working with us to bring up our new environment, that MMS needed 2.6 or newer as a backend, maybe I misunderstood
[19:27:36] <GothAlice> MMS is several things. Provisioning, monitoring, backup…
[19:56:02] <jthomas_> I've set up a database "use raycorp" and then set up perms for a user; then I exited Mongo and enabled auth=true in the config; I restarted Mongo; I log in remotedly without any auth, and I can use that DB. What do I need to lock down the DB if the Auth doesn't cut it?
[19:56:45] <jthomas_> oh i just can't do anything, but i can still select it.
[21:58:37] <tylerdmace> Looks like some old efforts to get it supported
[21:58:48] <tylerdmace> but stagnant projects nowadays
[22:02:42] <jthomas_> I seem to be locked out of my Mongo 2.6 setup; I've set "db.createUser" against ""userAdminAnyDatabase", db: "admin"" but now I can't seem to log in with that user
[22:03:10] <jthomas_> can anyone advise me on how to log in?
[22:07:10] <jthomas_> "mongo admin -uusername --password" got it.
[22:14:22] <rk6> Derick, ianp: thanks..I was actually trying to install graylog 2 which depends on java and mongodb. So I subsitiued java for openjdk (vs oracle) and wa thinking of building mongodb but from an attempt in the past to port Java I don't think I want to venture out on that exercise
[23:06:04] <tarwich> I'd like customers to be able to upload spreadsheets (11,000 rows) into my database and use them with the website. The spreadsheets don't share any data. What's the best strategy? New collection for each upload?
[23:06:28] <tarwich> If mongodb has support for something like this I'm happy to RTFM, but I just need a little direction.
[23:07:07] <tylerdmace> how many spreadsheets can each user upload
[23:59:25] <n3b-> I've a quick and easy question that I can't found this answer. I'm using mongodb to store logs. Not so much (2/secondes). I'm doing some queries to show logs (dates, and types). I was wondering when indexing is usefull with data like this one (adding every seconds)? I'm a newb with mongo.
[23:59:27] <joannac> if field1 = "String1" should that be returned?
[23:59:41] <joannac> n3b-: when your query takes too long
[23:59:53] <joannac> where "too long" is whatever you decide it is