orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Data purging mechanism

Open tomvit opened this issue 10 years ago • 6 comments

Hi, I need to implement a purging mechanism in my app for the data that are out of an active time range. My DB is over 6GB of size. I am thinking about two options:

  1. Using clusters to store data on a daily basis. The purging mechanism would simply drop and truncated all clusters that would be out of the active time range.

  2. Delete data from documents that would be out of the active time range.

I understood that the second option would create holes in the db which OrientDB reuses when storing new data, however, if there is a high fragmentation of the DB, would I need to compact the DB on regular basis?

If I chose the first option, would I be able to avoid holes and a need to defragment the DB? Also, would multiple clusters for a single document have any impact on the performance when selecting the data?

Thanks, Tomas

tomvit avatar Apr 17 '16 19:04 tomvit

@tomvit any of this options will lead to big changes in indexes. Is it ok for you ?

One more question , do you have or plan to have unique indexes in database, I mean indexes which ensure uniqueness of records.

andrii0lomakin avatar Apr 18 '16 09:04 andrii0lomakin

I am not using indexes. My data is time series data and I have built a tree structure that allows to store data ordered by year, month, day, minute ... it also stores aggregated values at various levels, it is pretty fast.

I am a bit worried that if I purge data on daily basis and would just delete them, I would need to run defragmentation often. I thought that dropping clusters would avoid holes in the DB, is it correct?

tomvit avatar Apr 18 '16 10:04 tomvit

@tomvit if you remove records by ranges, database will reuse free space for new records, you do not need to make compaction for that. But if you remove files you will create big disk fragmentation. So I would suggest you to remove records by ranges.

In such case you will waste a bit of disk space, about 10 bytes per each deleted record. If that is still not acceptable for you, you may combine 2 approaches, create clusters for month or year time ranges and remove them once a month or year. Please do not forget to run disk defragmentation periodically in such case.

andrii0lomakin avatar Apr 18 '16 11:04 andrii0lomakin

Thanks a lot for your suggestions. Disk fragmentation could indeed be an issue, however, when running the app on linux or SSD, it should not. Something to keep in mind though.

Regarding the waste of disk space, as you say 10 bytes per record, I expect to have around 1500 records per day and per a document and around 50 documents in total. In total this would waste around 700KB of data per day (when the whole day data would be purged), so compacting the DB would need to be run from time to time.

tomvit avatar Apr 18 '16 13:04 tomvit

@laa : I don't see why you mentioned the removal of files, to drop 'old' data. I understood from "tomvit" that the goal (like I also would like to implement) is to create clusters for each certain timeframe (eg one per day, week or month, etc). Then simply trash all that data of such timeframe by DROP CLUSTER.

-> is a cluster contained in an individual file ? If so, would a DROP CLUSTER remove that file ? If not, deleted space in the database files will be re-used by you other project (new cluster mechanism)

langhha avatar Jul 27 '16 10:07 langhha

@rdelangh

is a cluster contained in an individual file ? yes. each cluster is contained in individual file.

andrii0lomakin avatar Jul 27 '16 11:07 andrii0lomakin