@sandro Yeah, VACUUM usually helps a lot. I intentionally kept the file fragmented as it's the most fragmented file on my system :)
Generally I'm slightly worried to run direct sqlite commands against databases that are actively used by nix-daemon. Would be nice if nix-daemon provided a direct call for it: https://github.com/NixOS/nix/issues/5319