6

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.

2

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
4
  • Thanks for the comprehensive answer. Any idea how this thing could have grown to 15GB though? I recently updated to Big Sur, so the uptime is not measured in months so far. – mrtksn Dec 3 '20 at 18:00
  • @mrtksn I have no idea. Does the file shrink to 0 if you quit Safari? – nohillside Dec 3 '20 at 19:02
  • The size of the .db file itself is less than 1MB. The .db-wal file was over 15GB, so I deleted that after closing Safari. Now I checked, the .db-wal is 9MB. – mrtksn Dec 4 '20 at 20:14
  • 1
    I am sure that @nohillside's answer is correct and that it is safe to delete the file. But it is also true that the .db-wal files should not get so large and should drop to zero when you exit Safari. It should only continue to grow if your never reboot and you have Safari running all the time. It may be an indication of some issue with your Safari - I don't know what. – Gilby Dec 9 '20 at 3:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .