During the operation of mongodb, we plan to keep logibility data until a specific date (30 days from today) and delete it afterwards.

Asked 2 years ago, Updated 2 years ago, 102 views

Mysql operated it using the partition table, and MongoDB is considering the capped collection, but it seems that it can be set only with size and count.

I also considered creating and erasing the collection by date, but there was a statement that it could affect the database when the collection is deleted.

If you have any know-how in operating it, please share it with us ㅠ<

mongodb

2022-09-22 08:39

2 Answers

If it doesn't apply to the following, shouldn't we try to delete as much as we need from the collection through cron (schedule program execution)?

Do you think you can achieve your goal by running a program that deletes data from your collection periodically at a time when it's usually not in use?

[Additional Answer]

If it's a game service, there's a possibility that there's a load around the clock.

The performance of deleting the entire collection data is a problem, and deleting all elements of the collection is very slow, but deleting the entire collection is not likely to have a significant impact. If it's big enough to load up to the File System... I think it could be a problem, too.

db.some_coll.remove({}): // Delete all elements very slow
db.some_coll.drop(); // Delete collection entirely... I think you should test this.

And there seems to be a similar discussion in Stack Overflow.

If you look at another link, I recommend dropping the collection itself.


2022-09-22 08:39

I know that MongoDB can also set TTL for each collection.

If you set the TTL to one month, you don't have to delete it separately.

https://docs.mongodb.org/manual/tutorial/expire-data/


2022-09-22 08:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.