Skip to content

Database schema

DoppelSort stores its index in a single SQLite database. The schema is versioned with PRAGMA user_version and migrated on open, so older indexes keep working.

Images table

Image metadata includes:

  • image_path
  • content_hash
  • perceptual_hash
  • timestamp
  • file_size
  • mtime

Faces table

Face metadata includes:

  • id
  • image_path
  • bbox
  • embedding
  • embedding_norm
  • timestamp
  • content_hash
  • perceptual_hash
  • image_id

Schema version 2 enables foreign keys, references images(id) from faces.image_id, and enforces UNIQUE(image_id, embedding). Embeddings are stored as L2-normalized float32 BLOBs.

The metadata supports:

  • exact duplicate files through content_hash;
  • perceptual similarity metadata through perceptual_hash;
  • image records and their associated face detections.

Index metadata

scan records model_name and embedding_dim in index_meta. match refuses an index built with a different model or embedding dimension instead of comparing incompatible vectors. Legacy indexes without index_meta remain readable.

Duplicate grouping

db info and db optimize share one grouping key: content_hash plus the embedding, or image_path plus the embedding for legacy rows without a content hash. NULL content hashes fall back to the image path, so unrelated legacy rows are not merged.

  • duplicate_groups counts groups containing more than one row.
  • duplicate_rows counts the excess rows that db optimize would remove.

Compatibility

The database uses SQLite WAL mode. When scanning an older index, DoppelSort adds missing image and hash metadata columns while preserving existing face rows.