very slow full text search, sometimes crash of mongod

已查看 67 次
跳至第一个未读帖子

Marco

未读,
2016年9月25日 17:31:022016/9/25
收件人 mongodb-user
hi,

I created a text index like this:

{
    "brand" : 1,
    "color" : 1,
    "han" : 1,
    "name" : 1,
    "size" : 1
}

And I try to search for a keyword with this php code:

// select a database
$db = $m->computerdb;

// select a collection 
$collection = $db->products;

$result = $collection->find(array('$text' => array('$search' => 'Asus')), array('pictures' => 0))->limit(1);

// iterate through the results
foreach ($result as $document) {
    echo $document["name"] . "\n";
}

getting the one result takes more than one minute. Sometimes the database crashes in different ways, by doing exactly the same query: 

2016-09-25T15:16:15.008-0400 F -        [conn7] out of memory.

or 

2016-09-25T15:26:26.404-0400 E STORAGE  [conn3] WiredTiger (12) [1474831586:358439][1069:0x7f7395f5c700], file:collection-2-161678893487581897.wt, WT_CURSOR.search: memory allocation of 7098127 bytes failed: Cannot allocate memory
2016-09-25T15:26:26.540-0400 I -        [conn3] Invariant failure: seekRet resulted in status UnknownError: 12: Cannot allocate memory at src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp 527

I tried to increase the RAM from 4GB to 16GB and rewrote the text index but still the same problem. What am I doing wrong?


Kevin Adistambha

未读,
2016年10月6日 23:48:082016/10/6
收件人 mongodb-user

Hi,

I created a text index like this:

{
"brand" : 1,
"color" : 1,
"han" : 1,    
"name" : 1,    
"size" : 1
}

Is this the syntax you used to create the index? This looks like a regular compound index instead of a text index. Could you post the output of db.products.getIndexes() (assuming your collections is named products)?

2016-09-25T15:16:15.008-0400 F - [conn7] out of memory.

From the error, it looks like MongoDB is running out of memory while executing the query. However, you mentioned that you added more memory to the server, but the error persists.

Could you post more information:

  • Your MongoDB version
  • Your deployment topology (i.e. standalone, replica set, sharded cluster) and whether some other potentially resource intensive process is running in the same machine (e.g. other MongoDB processes, other databases, web servers, etc.)
  • Your hardware specification (i.e. CPU, memory) and if MongoDB is deployed in a virtual environment, the specification of the virtual environment.
  • (As mentioned above), the output of db.product.getIndexes()

Best regards,
Kevin

回复全部
回复作者
转发
0 个新帖子