From ac0041d47c1ddda9defd32da0a751a49473271dc Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Mon, 11 Mar 2013 13:14:57 -0400 Subject: [PATCH 1/2] DOCS-1044 updates to collMod for TTL collections --- source/reference/command/collMod.txt | 67 +++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/source/reference/command/collMod.txt b/source/reference/command/collMod.txt index 4f469b2b2b7..321d5536dd2 100644 --- a/source/reference/command/collMod.txt +++ b/source/reference/command/collMod.txt @@ -23,6 +23,7 @@ collMod .. index:: document; space allocation .. index:: usePowerOf2Sizes + .. _usePowerOf2Sizes: .. collflag:: usePowerOf2Sizes The :collflag:`usePowerOf2Sizes` flag changes the method that @@ -33,14 +34,19 @@ collMod With :collflag:`usePowerOf2Sizes` MongoDB will be able to more effectively reuse space. - .. note:: + .. COMMENT - With :collflag:`usePowerOf2Sizes` MongoDB, allocates - records that have power of 2 sizes, until record sizes - equal 4 megabytes. For records larger than 4 megabytes - with :collflag:`usePowerOf2Sizes` set, :program:`mongod` - will allocate records in full megabytes by rounding up to - the nearest megabyte. + Remove comment block following 2.4 release. + .. note:: + + With :collflag:`usePowerOf2Sizes` MongoDB, allocates + records that have power of 2 sizes, until record sizes + equal 4 megabytes. For records larger than 4 megabytes + with :collflag:`usePowerOf2Sizes` set, :program:`mongod` + will allocate records in full megabytes by rounding up to + the nearest megabyte. + + .. END-COMMENT :collflag:`usePowerOf2Sizes` is useful for collections where you will be inserting and deleting large numbers of documents to @@ -62,6 +68,7 @@ collMod db.runCommand( { collMod: "products", "usePowerOf2Sizes": false }) + .. warning:: .. versionchanged:: 2.2.1 :collflag:`usePowerOf2Sizes` now @@ -74,10 +81,50 @@ collMod as a result of document growth, and *does not* affect existing allocations. - .. note:: + .. index:: expireAfterSeconds + .. _update_expireAfterSeconds: + .. collflag:: index + + The :collflag:`index` flag changes the expiration time of a + :doc:`TTL Collection `. + + Specify the key and new expiration time with a document of the form: + + .. code-block:: javascript + + {keyPattern: , expireAfterSeconds: } + + where ```` is an existing index in the collection and + ``seconds`` is the number of seconds to subtract from the current + time. + + .. example:: + + To update the expiration value for a collection + named ``sessions`` indexed on a ``lastAccess`` field from 30 + minutes to 60 minutes, use the following operation: + + .. code-block:: javascript + + db.runCommand({collMod: "sessions", + index: {keyPattern: {lastAccess:1}, + expireAfterSeconds: 3600}}) + + Which will return the document: + + .. code-block:: javascript + + { "expireAfterSeconds_old" : 1800, "expireAfterSeconds_new" : 3600, "ok" : 1 } + + On success a document with fields ``expireAfterSeconds_old`` + and ``expireAfterSeconds_new`` set to the respective + values is returned. - :collflag:`usePowerOf2Sizes` has no effect on - :term:`capped collections `. + On failure, a document is returned with + ``no expireAfterSeconds field to update`` + if there is no existing ``expireAfterSeconds`` field or + ``cannot find index { **key**: 1.0 } for ns **namespace**`` + if the specified ``keyPattern`` does not exist. .. Commenting out the following after DOCS-717, it does take a lock but its to cover a very small metadata change. From 4e98c040d597b7bfafa29b629fd4a7769dfb2494 Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Mon, 11 Mar 2013 13:48:55 -0400 Subject: [PATCH 2/2] DOCS-1044 minor cleanup --- source/reference/command/collMod.txt | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/source/reference/command/collMod.txt b/source/reference/command/collMod.txt index 321d5536dd2..608ff86b639 100644 --- a/source/reference/command/collMod.txt +++ b/source/reference/command/collMod.txt @@ -34,20 +34,15 @@ collMod With :collflag:`usePowerOf2Sizes` MongoDB will be able to more effectively reuse space. - .. COMMENT - - Remove comment block following 2.4 release. - .. note:: - - With :collflag:`usePowerOf2Sizes` MongoDB, allocates - records that have power of 2 sizes, until record sizes - equal 4 megabytes. For records larger than 4 megabytes - with :collflag:`usePowerOf2Sizes` set, :program:`mongod` - will allocate records in full megabytes by rounding up to - the nearest megabyte. - - .. END-COMMENT - + .. note:: + + With :collflag:`usePowerOf2Sizes` MongoDB, allocates + records that have power of 2 sizes, until record sizes + equal 4 megabytes. For records larger than 4 megabytes + with :collflag:`usePowerOf2Sizes` set, :program:`mongod` + will allocate records in full megabytes by rounding up to + the nearest megabyte. + :collflag:`usePowerOf2Sizes` is useful for collections where you will be inserting and deleting large numbers of documents to ensure that MongoDB will effectively use space on disk. @@ -82,7 +77,6 @@ collMod existing allocations. .. index:: expireAfterSeconds - .. _update_expireAfterSeconds: .. collflag:: index The :collflag:`index` flag changes the expiration time of a