https://github.com/guardianproject/libsqlfs
or something similar to check the potential for speed up.