[SERVER-6700] Allow updates to expireAfterSeconds field for TTL indexes Created: 03/Aug/12  Updated: 16/Nov/21  Resolved: 24/Dec/12

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Usability
Affects Version/s: 2.1.2
Fix Version/s: 2.3.2

Type: Improvement Priority: Minor - P4
Reporter: Kevin Matulef Assignee: Kevin Matulef
Resolution: Done Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DOCS-1044 Document process to update expireAfte... Closed
Related
related to SERVER-211 TTL collections Closed
is related to SERVER-6701 TTL expiration using _id index Closed
Participants:

 Description   

This can be accomplished using the collMod command. The syntax for changing the value of the expireAfterSeconds field is:

db.runCommand( {"collMod" : [collection] , "index" : { "keyPattern" : [indexPattern] , "expireAfterSeconds" : [newVal] } } )

For instance:

db.runCommand( {"collMod" : "foo" , "index" : { "keyPattern" : {a : 1} , "expireAfterSeconds" : 3600 } } )



 Comments   
Comment by auto [ 08/Jan/13 ]

Author:

{u'date': u'2013-01-08T19:49:45Z', u'email': u'tad@10gen.com', u'name': u'Tad Marshall'}

Message: SERVER-6700 Remove race in part 3 of test

Wait for replication before checking secondary in part 3.
Branch: master
https://github.com/mongodb/mongo/commit/e703648398e5e6df847483422bb56b5523b62595

Comment by auto [ 25/Dec/12 ]

Author:

{u'date': u'2012-12-25T01:11:05Z', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

Message: SERVER-6700 fix test
Branch: master
https://github.com/mongodb/mongo/commit/5f453739cc2d4f17341395115a2d27cda5894f38

Comment by Kevin Matulef [ 24/Dec/12 ]

This can now be accomplished using the collMod command. The syntax for changing the value of the expireAfterSeconds field is:

db.runCommand( {"collMod" : [collection] , "index" : { "keyPattern" : [indexPattern] , "expireAfterSeconds" : [newVal] } } )

For instance:

db.runCommand( {"collMod" : "foo" , "index" : { "keyPattern" : {a : 1} , "expireAfterSeconds" : 3600 } } )

Comment by auto [ 24/Dec/12 ]

Author:

{u'date': u'2012-12-24T22:30:16Z', u'email': u'matulef@gmail.com', u'name': u'Kevin Matulef'}

Message: SERVER-6700 allow updates to TTL expiration time using collMod
Branch: master
https://github.com/mongodb/mongo/commit/a3a5fd617cc9bc7df0083c60094ec6d804ddba3a

Comment by Kevin Matulef [ 24/Sep/12 ]

This is a simple theoretical change, but a bit trickier to implement than it sounds.

For the time being, a workaround is to declare a normal (non-TTL) index on the time-based field you want to use, then use the collMod command to change the memory allocation scheme for the collection:

db.runCommand( {"collMod" : [collection] , "usePowerOf2Sizes" : true } )

and finally write your own external script that simulates the TTL monitor by deleting old docs every 60 seconds or so. It's not the most elegant solution, but it may be preferable if you frequently change your definition of "old."

Comment by David Snelling [ 24/Sep/12 ]

This would be huge for us. We are just having to do this week against a very large dataset. TTL has been a critical and great feature for us in our analytics to handle sliding windows.

Comment by Eldar Insafutdinov [ 24/Sep/12 ]

+1

Comment by David Snelling [ 24/Sep/12 ]

1++

Comment by Vineeth Narayanan [ 05/Sep/12 ]

+1

Generated at Thu Feb 08 03:12:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.