0

I use java edition of BerkeleyDB, DPL.

While parsing a data to BerkeleyDB I store some temporal information in specific PrimaryIndex. This PrimaryIndex takes lot of space and I want to drop all data stored there and to free the space used on HD.

What is the simpliest way to do this?

Thanks.

jutky
  • 3,895
  • 6
  • 31
  • 45

3 Answers3

1

In principle you may need to:

  • Alter the table structure to change the primary index to another column, as BDB tables need a primary key
  • Alter the table structure to remove the column you no longer want

Peter is right, we need more specific details (such as the table structure DDL) before we can give you any specific answers.

See:

Dan Hardiker
  • 3,013
  • 16
  • 19
  • I don't have any table structure, I use Direct Persistence Layer (DPL). My java objects are stored in BTrees, I just specify the primary keys (with annotations) on those objects. – jutky Jan 08 '12 at 12:26
  • Sorry - I missed the first line of your question. I've only used BDB through a SQL handler (like MySQL). I think Peter is right - you'll probably need to create a new data structure and migrate data into it. – Dan Hardiker Jan 08 '12 at 12:30
0

Without knowing more details, you may nee to re-write the data without the information you want to drop. However, Unless you are looking to save hundreds of GB, I wouldn't bother. I would get more disk space if you need it.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • My db is ~45Gb and I suspect that half of that is temporal information that I don't need. Isn't there any equivalence to DROP TABLE in BDB? – jutky Jan 08 '12 at 12:23
  • 1
    DROP TABLE would drop the entire table and all information with in (not just the column you want to get rid of), I suspect you want to effectively ALTER TABLE. – Dan Hardiker Jan 08 '12 at 12:26
  • 20 GB is worth about £1. Its worth doing if it simple, but I suspect its not and may not be worth worrying about. – Peter Lawrey Jan 08 '12 at 12:30
0

I believe you'll need to do the following:

  1. Create a new table structure, with the architecture you want
  2. Read each line from the old structure and migrate it into the new structure, modifying it as you go along (dropping / otherwise mutating the data)
  3. If space is of concern, even temporarily, remove the data from the old table as you go

Whether the above is suitable will depend on the detail.

This would be easier with a SQL database, using the ALTER TABLE syntax, but I expect there are reasons for your design decisions (likely performance based).

Dan Hardiker
  • 3,013
  • 16
  • 19