Speedup Package Management

Speeding up the package manager

Package Management is one part of the system where massive databases are thrown around, changed incrementally and is generally used heavily. Due to incremental nature of modifications it will cause the databases used to fragment, both internally (in the database blob) and externally (on the disk).

In openSUSE 10.3 we have two kinds of databases for package management.

Defragment internally

For the ZYPP cache database:
sqlite3 /var/cache/zypp/zypp.db vacuum
Or alternatively regenerate it from scratch:
rm /var/cache/zypp/zypp.db ; zypper refresh
After largish update it is helpful to run rpm --rebuilddb once.
This is just necessary after lots of packages changed/updated/installed and takes some time (10 minutes on a Laptop).

Defragment externally

While Linux filesystems try to not create heavily fragmented files, the slow increasing nature of the databases used in packagemanagement has fragmentation patterns.

So to best way to get rid of it, is to recreate the files using the pattern:

cp file file.new  # check for errors!
rm file
mv file.new file
Either remove it and regenerate it using zypper refresh or just apply
the cp/rm/mv on /var/cache/zypp/zypp.db.
Use the cp/rm/mv trick on /var/lib/rpm/Packages, Basenames, Filemd5s, Dirnames

Sample script

#!/bin/sh
sqlite3 /var/cache/zypp/zypp.db vacuum
rpm --rebuilddb         # takes long
for fn in       /var/cache/zypp/zypp.db \
                /var/lib/rpm/Packages   \
                /var/lib/rpm/Filemd5s   \
                /var/lib/rpm/Dirnames   \
                /var/lib/rpm/Basenames
do
        cp $fn $fn.new || exit 1
        rm $fn
        mv $fn.new $fn
done

zypp,rpm,speed,package management

C C C


Revision #3
Created 2026-04-01 17:11:09 CEST by Philip
Updated 2026-04-13 19:25:46 CEST by Philip