Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4029656
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:22:23+00:00 2026-05-20T11:22:23+00:00

I decided to use Berkeley DB’s compaction feature to optimize the size and cache-hit

  • 0

I decided to use Berkeley DB’s compaction feature to optimize the size and cache-hit rate of my databases after some records were altered (shrinked), leaving “holes” in the database.

However, it doesn’t work. Not even with this very simple reduced piece of code:

if (db->open(db, NULL, dbFile, NULL, DB_HASH, DB_CREATE | DB_TRUNCATE, 0)) {
  // Error...
}

if (res = db->compact(db, NULL, NULL, NULL, NULL, DB_FREE_SPACE, NULL)) {
  db->err(db, res, "Compacting failed");
}

I tried specifing the fifth parameter or leaving out the flag, but still it fails with EINVAL (code 22) every time:

Compacting failed: Invalid argument

(too bad that there isn’t a preciser error message; most Berkeley DB errors have them)

It works if I replace DB_HASH with DB_BTREE, which is why I believe it has something to do with using the hash db format. However, according to the documentation, compacting hash tables should work just fine.

Has anybody got an idea what might cause this error?

PS: I am using Berkeley DB 4.5.20.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:22:24+00:00Added an answer on May 20, 2026 at 11:22 am

    I searched through the change logs for the last several releases of Berkeley DB. The change log for release 5.0 states “Added hash databases support to the DB->compact interface. [#16936]”. Although the online documentation for the current release says that DB->compact works for Btree, Recno and Hash databases, support for Hash was added in release 5.0.

    You may also want to post your question to the Berkeley DB Forum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I decided to use LINQ to SQL in my personal project after hearing lots
We decided to use mongodb for some web application (instead of mysql) but want
If I decided to use some javascipt in my website like $('#body').load(URL); or $.get(URL,
We've just newly decided to use NServiceBus on our project and we're experiencing some
After a bit of investigation I decided to use Carrierwave and mini_magick on my
We've decided to use webstart for deploying some of our applications. The problem is,
for showing full size images on my site I've decided to use Jquery.colorbox ,
So I've decided to use Quartz.NET to schedule some tasks for me in my
I've decided to use the 960 grid for a project and would like some
For my project i need a editable text ,so i decided to use some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.