• Contact Us
  • Home
  • Maintenance

Compact MDB File Size

Discover effective strategies to reduce the size of your Microsoft Access MDB files for better performance and efficiency.

Written by Maryanne Normann

Updated at September 11th, 2025

  • Quick Start
  • Installation
    Best Practices Configuration Troubleshooting Design Performance Platform
  • Maintenance
    Releases Upgrade
  • Reference
+ More

Date: 17-01-2022

Compacting an LMDB database using mdb_copy involves creating a new, smaller copy of the database by omitting free pages and renumbering the remaining pages sequentially. This process can reduce the overall size of the database file, especially if there has been significant data deletion or modification that has left behind many free pages.

mdb_copy is part of the mdbtools package and can be installed using:

sudo apt update
sudo apt install mdbtools

While mdb_copy can create a consistent copy even with active read transactions, it is generally recommended to minimize or eliminate active write transactions during the compaction process to ensure the most up-to-date and accurate copy.

1. Stop the slapd process:

sudo systemctl stop slapd 

or

sudo service slapd stop 

2. Make a backup location. Choose a location with enough space:

mkdir /tmp/backup

3. Use mdb_copy to make a non-sparse copy of the database. -c may be used while copying to compact the mdb file. Only current data pages will be copied when using -c; freed or unused pages will be omitted from the copy. This option will slow down the backup process as it is more CPU-intensive. Currently it fails if the environment has suffered a page leak.

mdb_copy /var/symas/openldap-data/<database dir>/ /tmp/backup/

or

mdb_copy -c /var/symas/openldap-data/<database dir>/ /tmp/backup/

4. Remove existing .mdb files from /var/symas/openldap-data:

sudo rm -rf /var/symas/openldap-data/<database dir>/*.mdb 

5. Replace with the copy that you created with mdb_copy:

sudo cp /tmp/backup/*.mdb /var/symas/openldap-data/<database dir>/

6. Start solserver/slapd:

sudo systemctl start slapd

or

sudo service slapd start
Copyright © 2020-2024 Symas Corporation. All rights reserved.
mdb compression

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • LMDB Database File Sizes and Memory Utilization
  • OpenLDAP and LMDB Sizing Guide
  • Solving Slow Write Performance
  • Symas Blog RSS Feed
  • Symas on Facebook
  • Symas on Twitter
  • Symas Blog
  • Symas on LinkedIn
  • Symas YouTube Channel

Copyright © 2023, Symas Corporation. All rights reserved. Privacy Statement (updated July 31, 2023)

Phone:

Main Office: +1.650.963.7601
Fax: +1.650.390.6284

Email:

Sales: sales@symas.com
Support: support@symas.com

Office Hours:

8:00 AM - 5:00 PM ET

Office Location:

Symas Corporation
PO Box 391
Grand Junction, CO 81507 USA

Expand