[00:00:26] <kurushiyama> Freman: if it is for development... ...well, sure. Why not? If it helps, you can have a second person type in the query after reviewing it. Will it help with existing indices which lack a field for sorting, for example?
[00:00:48] <kurushiyama> Freman: I prefer good ol' handywork.
[00:02:42] <Freman> tbh I'm making it up as I go along, they break it I find out how and fix it. it really just checks to see if the first field in the query is a first field in any index. doesn't stop them from putting in 1970-01-01 as a date but it is stoping me from getting woken up at 2 am because they crashed/cancelled out on a bung query on the wrong collection (one that doesn't even have the field their looking for)
[00:04:29] <kurushiyama> Freman: provide them with dev instances. And have profiling enabled with 75ms slow queries. Have them read them manually using the shell. ;)
[00:05:19] <Freman> wish I could, but they're querying production log data (which is a stupid amount of logging - why log the error for a request and a reference when when we can log the entire 8k request and html error page)
[00:06:47] <Freman> yeh and their bung queries stall mongo and cause my logging engine (which I had to write because they swamped whatever was there before) to backlog (it was designed to do that)
[00:07:16] <Freman> I'm trying to negotiate the moving of audit type logs to a dedicated collection and everything else into a capped collection with disk copy (and logrotate)
[00:07:34] <Freman> will make the whole thing more sane (and is something I can easily code :D)
[00:08:14] <kurushiyama> Freman: Erm... ...kill me, but rsyslog + logrotate does not do it?
[00:09:00] <Freman> all of this is to facilitate a real time log ui (a webpage with a socket that I could also just as easily pipe to from the re-written logging engine)
[00:10:23] <Freman> so yes, rsyslog + logrotate + capped collection should do everything they want from the real time logging view and audit collection for things that probably shouldn't just be dumped into the same place as "your request failed, here's 8k of rubbish no-one wille ver read"
[00:12:09] <kurushiyama> jiffe: I dont see a possibility not to resync
[00:12:18] <Freman> I am aware that we're crap, I'm trying to fix it
[00:12:38] <kurushiyama> jiffe: Hope you have another secondary running...
[00:13:20] <kurushiyama> Freman: send them by mail do the dev maling list... ;P
[00:13:48] <Freman> it's funny you should say that kurushiyama :D
[00:14:47] <Freman> From our logging wiki page (which I wrote when I had to re-write the logging engine to deal with the load) "We log everything, sometimes even logging that we've logged logs, and because of the quantity of logs, sometimes we even email that we've logged it."
[00:15:24] <kurushiyama> Freman: if you send every incident, maybe the devs notice that they overdo it... ;)
[00:15:28] <Freman> Yeh apparently, I'm stuck with more the making things build getting agents working (holy cow they're expensive - I come from jenkins where they're all 'free')
[00:15:58] <kurushiyama> Freman: That's a bit comparing apples with pears.
[00:16:13] <Freman> apples with pears that are hammers that make everything look like nails
[00:16:16] <kurushiyama> Freman: what you actually pay for is the integration, imho.
[00:16:26] <kurushiyama> Freman: That was a good one!
[00:17:52] <Freman> I don't know about integration I'm still doing all the same things I was doing under jenkins to get the builds working... but instead of having containers with an agent for each type of job that can be spun up and down as load dictates I now have containers per agent... that I've yet to figure out. but that's a bit off topic for #mongodb
[00:18:20] <kurushiyama> Freman: right. So, need to hit the hay.
[00:49:18] <jiffe> well this secondary thinks its last optime is 56c0be5f:5 and minvalid is 56c0be65:15, can I somehow change last optime to 56c0be65:15 on the secondary?
[04:15:50] <DocMerlin> Hello, how do I find out what my shard key is?
[04:16:38] <DocMerlin> I have a rather large (2TB) sharded collection and I need to find out what the shard key is to speed up some queries.
[04:30:40] <Freman> don't suppose anyone knows how mongo does their videos, that thing with the hand writing on a whiteboard, that's actually pretty cool
[07:49:37] <Zelest> Is it possible to use $addToSet and only check if some of the element exists? E.g, if I have an array with objects.. [{a: 1, b: 'foo'}, {a: 2, b: 'bar'}] .. I wish to update and add a object with a: 1, but only if it doesn't exists and it shouldn't add another one even if b: is something different than 'foo' .. Is this possible
[08:46:35] <sabrehagen> how do i restructure this logic using a query to reduce my number of database accesses? i have a query that returns documents in a certain time range. each document has a device id. for each of those documents i want to see if there is a document matching
[08:46:44] <sabrehagen> that device id in the 10 seconds prior. the initial number of documents can be 40,000+. my logic then sends 40,000 database queries to check the second piece of criteria.
[08:46:49] <sabrehagen> without the aggregation framework, how would i minimise the number of queries?
[09:32:08] <kurushiyama> sabrehagen: Sounds like there is something fundamentally wrong with your data model.
[09:36:18] <Lachezar> Hey all. What's the "MongoDB Way" of doing searches of documents by properties in related documents? Let's say an db.Order(id) has reference to db.Customer(id, name) and to a db.Employee(id, name). How should I do the model? I want to be able to search orders by text (quick-search) using the name of the customer OR employee?
[09:39:17] <kurushiyama> Lachezar: IN general, that is a relation with attributes: The Order relates the Customer to the Employee, but is itself qualified by attributes.
[09:40:08] <Lachezar> kurushiyama: I did not understand that. How is Order "qualified"?
[09:40:15] <kurushiyama> Lachezar: I would have an additional field in the order with the customers and employees name,
[09:40:38] <kurushiyama> lachezar: It isnt a "simple" relation, but on that has attributes itself.
[09:40:45] <Lachezar> kurushiyama: Ah. And how would I keep them in sync?
[09:42:40] <kurushiyama> Referential integrity is so 90s. Nad SQLish ;)
[09:42:41] <Lachezar> kurushiyama: Hm. Well... Yes. That might work with the simple pointer relations. But I understand where this i sgoing.
[09:42:57] <kurushiyama> Lachezar: They arent automatic, either.
[09:43:17] <kurushiyama> Lachezar: A text search via DBRef is not possible.
[09:44:04] <kurushiyama> Lachezar: Data modelling with mongodb involves redundancy. The earlier you get used to it, the better you models will become.
[09:46:30] <Lachezar> kurushiyama: redundancy… That word is badly used here. Redundancy (in IT) is typically meant to provide a measure of stability, failure tolerance and coping with critical events while possibly reducing performance. What you describe seems uite the opposite.
[09:47:46] <Lachezar> kurushiyama: Thank you for the time. I'm going to say that searches in MongoDB come at a price.
[09:48:13] <kurushiyama> Lachezar: I am in the industry for like 20 and a bit and have done huge projects with MongoDB. MongoDB is not just the cooler MySQL. You _really_ need to rethink the way you model data.
[09:48:59] <kurushiyama> Lachezar: Will try to issue the next post these days.
[09:52:09] <kurushiyama> Lachezar: To put it a bit simplified: You model data according to your questions, not according to the entities.
[10:18:47] <sabrehagen> kurushiyama: would be interested in reading part 2 of that blog
[10:19:42] <kurushiyama> sabrehagen: Well. It is a side project (sadly), and I first have to feed the family. If you have things that especially interest you, please add it in the comments.
[10:19:57] <kurushiyama> sabrehagen: But I'll do my very best.
[13:51:10] <Ben_1> is there a difference between bulkWrite and insertMany?
[14:14:13] <Zelest> I remember when people used to speak in here :
[14:43:25] <kurushiyama> Zelest: Yup. Got warned today for telling someone (in much nicer words) that he can *piep* himself and do his *piep* work himself. Wanted a complete business logic for a booking website.
[14:50:59] <Zelest> yeah, slice works as well for me.. no issues there
[14:51:12] <Zelest> (seeing i sort it beforehand, so the first element is always the one I want)
[14:51:33] <Zelest> but it's the upsert part i find messy
[14:51:52] <Zelest> I basically want to use a $addToSet, but have it check only one sub-element.. if that makes sense
[14:52:18] <kurushiyama> Zelest: using $elemMatch is cheaper, iirc. Well, in that use case, I'd fetch the whole array and push it. But I think it is rather a modelling problem.
[14:52:45] <kurushiyama> If arrays need to be updated fairly often, from my experience, you might be better of with a collection.
[16:30:05] <Ange7> is it possible to modify default timeout for aggregate() in mongo configuration file ? cause timeout() function in php driver doesn't work for me ?
[16:31:43] <Derick> server side? client side? cursor? What's your (simplified) code? What's the full error you get with the timeouts? And what does "timeout() doesn't work" mean?
[16:32:00] <Derick> Also, which driver? Which version of the driver?
[18:40:14] <StephenLynx> shiggidy diggity mah niggy
[18:43:22] <Ben_1> MongoCollection<Document> collection = database.getCollection(collectionKey); <<< in java this line should be enough to create a collection, but robomongo says there is no collection. could something go wrong by creating a collection? and what happens if I create a collection but do not insert something?
[18:46:15] <Ben_1> after this line the collection variable is not null
[18:51:18] <Ben_1> ok it seems my singleResultCallBack is not called so I think something wents wrong by using insertMany
[19:14:46] <Ben_1> someone using the async driver too?
[19:19:45] <cheeser> that line will not createa collection
[19:20:14] <cheeser> not in the db anyway. you'll get a MongoCollection reference but that doesn't mean it's backed by anything yet.
[19:21:09] <Ben_1> yah but when I insertMany in that reference it should be created, or not?
[19:32:52] <Ben_1> but anyway I'm using Robomongo GUI to look inside my database and it shows the database but no collections.
[19:33:47] <cheeser> strange. i haven't used the async driver so i'm not sure what else might be off.
[19:34:28] <Ben_1> found several tutorials but all are providing the same code that I use
[19:36:54] <Ben_1> cheeser: mh it seems in the log file no command is executed. Creating the database programmatically will work but the insertMany not
[20:49:52] <cheeser> jurassic park. "they spent so much time to wondering if they *could* do something they never stopped to wonder if they *should*"
[20:53:27] <kurushiyama> cheeser: That pretty much subsumizes every SO question about MongoDB I have seen in the last half year (which wasnt a "do my (home)work" or "I dont want to read the docs, I rather ask here").
[21:17:24] <cheeser> but having worked on a CMS at scale, i'm aware of the various limitations in that approach. they're just not likely to apply to someone asking in iRC at this point ;)
[21:18:30] <kurushiyama> cheeser: Well, and now the app becomes the next best thing and the OP sends his gorillas to kick you in the but for suggesting a data model which does not scale well ;)
[21:19:23] <cheeser> kurushiyama: when that happens, i'll happily take the heat. but it's not gonna. :)
[21:19:40] <cheeser> and for someone trying to learn mongodb, those are complications they needn't worry about just yet.
[21:21:31] <kurushiyama> cheeser: I see this quite different. The sooner people start to get used to redundancy and to model their data according to their questions as opposed to modelling according to their entities, the better for all of us.
[21:25:36] <kurushiyama> cheeser: Could you clarify your thoughts to me? I am really curious...
[21:27:19] <cheeser> well, part of my job is to help people get started. in this case, it feels more like an exploratory "what is mongo?" project. had it been, "we're migrating our customer service systems to mongo" it'd warrant a different response.
[21:27:50] <cheeser> when someone asks me how to get started building a website, i don't start by discussing scaling issues faced by facebook and twitter.
[21:28:52] <kurushiyama> cheeser: Well, Adam taught me this approach ;)
[21:43:47] <kurushiyama> cheeser: Adam Comerford, used to be instructor at MongoU
[21:45:29] <cheeser> ah. yeah. well your suggestion and how i'd actually do it only differ in that i'd keep a count on the article documents, too.
[21:47:11] <kurushiyama> cheeser: I'd rather use an aggregation for it than to store it manually. But granted, that may be just me. And granted, our solutions differ more on a philosophical level than a technical level.
[21:47:51] <cheeser> you'd pay that cost everytime you need the count?
[21:48:13] <cheeser> which would be, for many websites, every time the article is rendered?
[21:51:10] <kurushiyama> cheeser: An aggregation can have a match phase, and doing an aggregation is more reliable than doing a .count(), but still less harder to keep in check than updating a post document every time a like is added. There is an interesting problem related to doing counts in a sharded env: https://jira.mongodb.org/browse/SERVER-3645
[21:51:29] <kurushiyama> cheeser: reads are cheap, after all.
[21:52:51] <cheeser> cheaper still to just stick that count on the article ;)
[21:56:24] <kurushiyama> Well, probably I'd do an $inc on a counter, if the application really takes off. With document level locking, it does not hurt so much any more.
[22:44:03] <synapse> I am trying to build a function in nodejs like this searchUsers(query) which passes query to this db.collection.find(query) but it's proving difficult. escaping characters seems like a bad thing to do to get a literal query so what's "the right way"
[22:56:09] <StephenLynx> which characters you want to escape?
[22:56:33] <StephenLynx> what exactly is your problem, synapse ?
[23:05:25] <synapse> I've solved it but do I need to escape anything StephenLynx
[23:06:06] <synapse> find({ "name": variable }); where variable is passed as a parameter