Questions tagged [capped-collections]

A fixed size collection of elements sorted by insertion order

A capped collection is a fixed size collection of elements sorted by insertion order. Once the capped size has been reached, the collection behaves like a circular queue, overwriting the oldest elements with any new elements.

47 questions
14
votes
1 answer

Creating a capped collection using Spring data MongoDB @Document

I am trying out reactive support in spring-data with MongoDB. I am using spring-boot 2.0.0. Generally I would write a domain object like this in my project: @Document public class PriceData { ...... } With this spring-data it would create a…
pvpkiran
  • 25,582
  • 8
  • 87
  • 134
7
votes
2 answers

MongoDB 2.4.8 capped collection and tailable cursor consuming all memory

We are currently exploring Capped Collections and Tailable Cursors within MongoDB to create a queueing system for notifications. However, after creating a simple LinqPad test (code below) we noticed when running, Mongo constantly allocates memory…
Needleski
  • 125
  • 1
  • 8
5
votes
1 answer

mongodb - capped collections with nodejs

I'm trying to set up and update some capped collections in MongoDB using Node.js (using the native MongoDB driver). My goal is to, upon running app.js, insert documents into a capped collection, and also to update existing documents in a capped…
Simon
  • 9,762
  • 15
  • 62
  • 119
4
votes
2 answers

Mongodb: how to create a `tail -f` view on a capped collection?

I would like to create a sort of a 'dashboard' on a capped collection (which is used as a log table) on my Mongo database. This is how I create the collection: db.createCollection( "messages", { capped: true, size: 100000 } ); I do a…
MarcoS
  • 17,323
  • 24
  • 96
  • 174
4
votes
1 answer

Processing jobs from capped collection until interrupted using ReactiveMongo

I have a jobs_queue collection in MongoDB. It's a capped collection which I'm polling using a tailable cursor: val cur = jobsQueue .find(Json.obj("done" -> Json.obj("$ne" -> true))) .options(QueryOpts().tailable.awaitData) …
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
3
votes
1 answer

Tailable cursor vs Change streams for notifications of insert operations in capped collections

I am curious about the benefits and drawbacks of using a tailable cursor versus a change stream with filter for insert operations over a capped collection both in usability and performance-wise. I have a capped collection that contains update…
zhulien
  • 5,145
  • 3
  • 22
  • 36
3
votes
1 answer

How to convert a MongoDb's capped collection to non-capped collection?

Due to some specific business requirement we were storing data into the MongoDB's capped collection but now complete requirement changed and we want ot preserve all records in that collection. I am able to find "convertToCapped" command but didn't…
Vipul
  • 1,563
  • 4
  • 22
  • 46
3
votes
1 answer

Is hint({$natural: 1}) redundant when using a tailable cursor?

In many examples I find for using tailable cursors on capped collections, the code includes: hint( { $natural: 1 } ) (e.g. here), including the official docs (here), to "ensure we don't use any indexes", and that results are returned in natural…
shx2
  • 61,779
  • 13
  • 130
  • 153
3
votes
1 answer

why MongoDB will not remove older documents if a capped collection reaches the maximum size?

I have a capped collection, which was created in java-code: this.collection = db.createCollection("stat", new BasicDBObject("capped", true).append("size", 200000000).append("max", 1000000)); Now in statistics for this collection we have: /* 0 */ { …
flutesa
  • 469
  • 5
  • 5
2
votes
0 answers

How can I create a capped collection by storageSize instead of dataSize?

Running MongoDB 4.0.4 on Debian GNU/Linux 9 (stretch), with a collection capped in size to 2.9TB with unlimited number of documents with the WiredTiger engine. { ... "size" : NumberLong(3113851252530), // <= ~2.9T "count" : 238059628, …
Percutio
  • 979
  • 7
  • 8
2
votes
1 answer

Convert Collection to Capped with mgo

I would like to convert a mongo collection to capped using gopkg.in/mgo.v2. I am able to create a capped collection from scratch - as follows: # Create a Capped Collection sess.DB("").C("my_collection").Create(&mgo.CollectionInfo{Capped: true,…
Gravy
  • 12,264
  • 26
  • 124
  • 193
2
votes
0 answers

MongoDB Capped Collection For Storing SQL Data Repeatedly

I'm querying a SQL database and want to save the query results in a local mongo db repeatedly (e.g. every 30 minutes). The SQL data is not very consistent that is to say that there are many null values. The data which I want to save has this…
Matthias Herrmann
  • 2,650
  • 5
  • 32
  • 66
2
votes
1 answer

How to update a single field in a capped collection in MongoDB?

db.events.update( {upload:0}, {$set:{upload:1}}, {multi:true} ) I am getting the following error even though I am just replacing an integer with another integer. Cannot change the size of a document in a capped collection: 402 != 406
Sathish
  • 409
  • 8
  • 24
2
votes
1 answer

Is it possible use MongoDb capped collection with phalcon Collection models

I use some mongoDb collection for logs, so I want use MongoDb capped collection. Can I use phaclon Collection for doing it, or I should code log rotation inside my log model?
vologa
  • 37
  • 1
  • 5
2
votes
1 answer

Mongoose: how to get data from a capped collection in an express.js app?

I'd like to listen on a MongoDB capped collection, using it as a logging facility. I use node, express.js, mongo (with mongoose). This is the (simplified) code I come with up to now: var mongoose =…
MarcoS
  • 17,323
  • 24
  • 96
  • 174
1
2 3 4