Mozilla Flux

Mozilla関係の情報に特化したブログです。

Firefox 49本体のみで履歴等データベースのVACUUMが可能に

FirefoxはSQLiteというデータベース管理システムを用いて履歴とブックマークを管理しており、このデータベースのことをPlacesと呼ぶ。具体的にはplaces.sqliteというファイルだ。places.sqliteの肥大化と断片化はFirefoxのパフォーマンスを低下させるおそれがあるため、Firefox 3.6以降、データベースの断片化割合を推測しながら30日から60日に1回、アイドル時にVACUUM処理が行われる仕様となっている(Bug 512854)。places.sqlite内の項目が削除されて生じた空きレコードは、VACUUM処理によって解消され、それによって初めてファイルが圧縮されることになる。

ここまでは前提のおさらいだが、そうした知識があるかは別にして、要するにVACUUMすればFirefox本体の動作が軽くなると考えて、手動でこれを行うべく拡張機能を導入するユーザーが一定数存在する。実際には頻繁にVACUUM処理を実行してもあまり意味はないのだが、それはさておき拡張機能を入れるとなると互換性の問題が生じる。つまりFirefoxをバージョンアップすると動かなくなるケースが出てくるわけだ。

しかし、Firefox 49でトラブルシューティング情報(about:support)のページに「Places Database」(Placesデータベース)の欄が加わり、"Verify Integrity"(整合性の検証)というボタンが付いたことで、状況が変わるかもしれない(Bug 522668)。about:supportはロケーションバーに直接打ち込むか、メニューパネルのヘルプメニューから「トラブルシューティング情報」を選択すると呼び出せるが、そこにある整合性の検証ボタンをクリックすると処理が始まる。しばらく待つと結果が表示され、その中でVACUUM処理がされたことがわかる。処理前後のデータベースサイズを示してくれるので親切だ。

f:id:Rockridge:20160614000628p:plain

新規プロファイルで試してみた結果を以下に示しておこう。VACUUMの項目を見るとデータベースサイズは変わっていないが、削除された履歴やブックマークがない状態なのでこうなるのは当然である。

> Integrity check
+ The database is sane
> Coherence check
+ The database is coherent
> Orphans expiration
+ Database cleaned up
> Vacuum
Initial database size is 10240 KiB
+ The database has been vacuumed
Final database size is 10240 KiB
> Statistics
Database size is 10240 KiB
user_version is 32
page_size is 32768
cache_size is -2048
journal_mode is wal
synchronous is 1
History can store a maximum of 104858 unique pages
Table moz_places has 11 records
Table moz_historyvisits has 4 records
Table moz_inputhistory has 0 records
Table moz_hosts has 4 records
Table moz_bookmarks has 15 records
Table moz_keywords has 0 records
Table sqlite_sequence has 0 records
Table moz_favicons has 8 records
Table moz_anno_attributes has 3 records
Table moz_annos has 1 records
Table moz_items_annos has 4 records
Table sqlite_stat1 has 14 records
Index sqlite_autoindex_moz_inputhistory_1
Index sqlite_autoindex_moz_hosts_1
Index sqlite_autoindex_moz_keywords_1
Index sqlite_autoindex_moz_favicons_1
Index sqlite_autoindex_moz_anno_attributes_1
Index moz_places_faviconindex
Index moz_places_hostindex
Index moz_places_visitcount
Index moz_places_frecencyindex
Index moz_places_lastvisitdateindex
Index moz_historyvisits_placedateindex
Index moz_historyvisits_fromindex
Index moz_historyvisits_dateindex
Index moz_bookmarks_itemindex
Index moz_bookmarks_parentindex
Index moz_bookmarks_itemlastmodifiedindex
Index moz_places_url_uniqueindex
Index moz_places_guid_uniqueindex
Index moz_bookmarks_guid_uniqueindex
Index moz_keywords_placepostdata_uniqueindex
Index moz_annos_placeattributeindex
Index moz_items_annos_itemattributeindex

もはやPlacesをVACUUMするためにわざわざ拡張機能を入れる理由はなくなった。拡張機能を入れなければ、互換性問題に悩まされることもない。ただし、より高度なメンテナンスを行う場合は、Places Maintenanceのような拡張機能にもまだ出番がある。