QGIS – Understanding .gpkg-shm and .gpkg-wal Files in GeoPackage

geopackageqgis

In QGIS, if I open some GeoPackage file like mylayers.gpkg, it will create two files named mylayers.gpkg-shm and mylayers.gpkg-wal in the same folder. After I close QGIS, these files disappear. I understand that they are temporary files, but I wonder what their purpose is.

Best Answer

As the SQLite core of a GeoPackage is a single-file based RDB, it needs to utilize temporary support structures to guarantee atomic transaction management.

SQLite supports different mechanics to achieve this, and the QGIS specific GPKG implementation defaults to Write Ahead Logging (WAL), available in SQLite > 3.7, where

  • the *.gpkg-wal file holds the WAL for the current connection; this file keeps a progressive data log of the transactional state of the DB between COMMITs (or ROLLBACKs)
  • the *.gpkg-shm SHhared Memory file manages concurrent access to the DB via an index to the WAL
Related Question