Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:03:59+00:00 2026-05-29T20:03:59+00:00

I’m trying to test out mongoDb to manage our performance logs. For this test

  • 0

I’m trying to test out mongoDb to manage our performance logs.

For this test I inserted 10M rows in a collection using the following format

{ "_id" : ObjectId("4e9d3cc4621dc1dc11000000"), "date" : "Thu Oct 13 2011 15:37:21 GMT+0200 (CEST)", "loadtime" : 0.07, "msg" : "Lorem ipsum message" }

Now I would like to be able to get average load time by day.

So from what I understood I need to do 2 pass of MapReduce.

the first one would be to create a collection of days.

So I tried

map = function() {
  day = Date.UTC(this.date.getFullYear(), this.date.getMonth(), this.date.getDate());

  emit({day: day}, {count: 1});
}

reduce = function(key, values) {
  var count = 0;

  values.forEach(function(v) {
    count += v['count'];
  });

  return {count: count};
}

Refering to http://cookbook.mongodb.org/patterns/unique_items_map_reduce/

But this kills my mongodb server after a few seconds.

db.loadTime.mapReduce(map, reduce, {out: 'days'});
Tue Oct 18 11:57:28 query failed : test.$cmd { mapreduce: "loadTime", map: function () {
    day = Date.UTC(this.date.getFullYear(), this.date.ge..., reduce: function (key, values) {
    var count = 0;
    values.forEach(functio..., out: "days" } to: 127.0.0.1
Tue Oct 18 11:57:28 Error: error doing query: failed (anon):1509

Here is my error log

Tue Oct 18 11:56:08 [conn1] CMD: drop test.tmp.mr.mapreduce_1318931768_1_inc
        55800/10000000  0%
        112800/10000000 1%
        171400/10000000 1%
        229600/10000000 2%
        288600/10000000 2%
        345600/10000000 3%
        404100/10000000 4%
        462900/10000000 4%
        522000/10000000 5%
        579100/10000000 5%
        629200/10000000 6%
        677000/10000000 6%
        724200/10000000 7%
        767500/10000000 7%
        818600/10000000 8%
        864300/10000000 8%
        921300/10000000 9%
        972200/10000000 9%
        1021600/10000000    10%
        1070700/10000000    10%
        1115600/10000000    11%
        1163600/10000000    11%
        1217400/10000000    12%
        1269100/10000000    12%
        1313300/10000000    13%
        1366200/10000000    13%
Tue Oct 18 11:57:28 Got signal: 11 (Segmentation fault).

Tue Oct 18 11:57:28 Backtrace:
0x843a16d 0x842dbcd 0x741400 0x1eadcd 
 /usr/lib/mongodb/mongod(_ZN5mongo15printStackTraceERSo+0x2d) [0x843a16d]
 /usr/lib/mongodb/mongod(_ZN5mongo10abruptQuitEi+0x3ed) [0x842dbcd]
 [0x741400]
 /usr/lib/xulrunner-2.0/libmozjs.so(+0xdadcd) [0x1eadcd]

Am I going in the right direction ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:04:00+00:00Added an answer on May 29, 2026 at 8:04 pm

    I also got same problem and solve it as follows.

    Instead of

    values.forEach(function(v) {
       count += v['count'];
    });
    

    use

    for(v in values){
       count += v['count'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.