Remove primary index from berkeley db

372 views Asked by At

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.

3

There are 3 answers

3
Peter Lawrey On

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.

2
Dan Hardiker On

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:

0
Dan Hardiker On

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).