I found 15GB large file in ~/Library/Safari called ContentBlockerStatistics.db-wal. What is that and what to do with it?

apple.stackexchange https://apple.stackexchange.com/questions/407900

Question

I run out of space and when was looking what to clean up, I come across ~/Library/Safari/ContentBlockerStatistics.db-wal

The size is about 15GB, I tried to open it with SQLite db manager but it is asking for password.

What is this file about, why it is so large and what the password could be?

I'm running MacOS Big Sur.

Was it helpful?

Solution

TL;DR

  • ~/Library/Safari/ContentBlockerStatistics.db-wal is the log file for ~/Library/Safari/ContentBlockerStatistics.db
  • It can't be read directly and gets emptied once you quit Safari.
  • ~/Library/Safari/ContentBlockerStatistics.db can be read with sq3lite
  • If ~/Library/Safari/ContentBlockerStatistics.db grows too big it can safely be removed while Safari is not running

Using the standard tools of macOS

$ file ContentBlockerStatistics.db*
ContentBlockerStatistics.db:     SQLite 3.x database, user version 1, last written using SQLite version 3032003
ContentBlockerStatistics.db-shm: data
ContentBlockerStatistics.db-wal: SQLite Write-Ahead Log, version 3007000

So ContentBlockerStatistics.db is a database and the -wal file is the write-ahead log where all DB changes are written to while Safari is running. You can't browse the write-ahead log and the DB is locked while Safari is running. If you close Safari the write-ahead log content gets emptied.

$ file ContentBlockerStatistics.db*
ContentBlockerStatistics.db:     SQLite 3.x database, user version 1, last written using SQLite version 3032003
ContentBlockerStatistics.db-shm: data
ContentBlockerStatistics.db-wal: empty

To see what's inside ContentBlockerStatistics.db use sqlite3 (or any third-party MySql browser).

$ sqlite3 ContentBlockerStatistics.db
SQLite version 3.32.3 2020-06-18 14:16:19
Enter ".help" for usage hints.
sqlite> .schema
CREATE TABLE FirstPartyDomains (firstPartyDomainID INTEGER PRIMARY KEY AUTOINCREMENT,domain TEXT NOT NULL UNIQUE ON CONFLICT FAIL);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE ThirdPartyDomains (thirdPartyDomainID INTEGER PRIMARY KEY AUTOINCREMENT,domain TEXT NOT NULL UNIQUE ON CONFLICT FAIL);
CREATE TABLE BlockedResources (firstPartyDomainID INTEGER NOT NULL,thirdPartyDomainID INTEGER NOT NULL,lastSeen REAL NOT NULL,FOREIGN KEY (firstPartyDomainID) REFERENCES FirstPartyDomains(firstPartyDomainID) ON DELETE CASCADE,FOREIGN KEY (thirdPartyDomainID) REFERENCES ThirdPartyDomains(thirdPartyDomainID) ON DELETE CASCADE,PRIMARY KEY (firstPartyDomainID, thirdPartyDomainID));
  • FirstPartyDomains seems to contain the domains you visited
  • ThirdPartyDomains seems to contain any domains referenced from the first party domains
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top