Can I stop compaction?

87 views
Skip to first unread message

Jordan Wood

unread,
Dec 3, 2015, 10:50:01 AM12/3/15
to Couchbase Mobile
I have decided to do my database compaction when my app transitions into the background, so I am putting the call to compact in a background task using beginBackgroundTaskWithExpirationHandler.  I'm trying to figure out what to do if the OS decides that my background task has to stop before compact is done.  Can I call [database stop], to stop compaction?  I understand that compact spends most of its time in a few calls to SQLite, is there any way that be stopped gracefully?

Jens Alfke

unread,
Dec 3, 2015, 12:18:23 PM12/3/15
to mobile-c...@googlegroups.com
On Dec 3, 2015, at 7:50 AM, Jordan Wood <wood.p...@gmail.com> wrote:

Can I call [database stop], to stop compaction?  

Nope. Compaction is a synchronous operation and there’s no way to interrupt it. On the other hand, if you compact often, i.e. on ever suspend, the task won’t take very log since there’s not much to do.

This will improve a lot in CBL 1.2 with ForestDB databases — the db will auto-compact periodically without you needing to do anything, and the background compaction task can handle being interrupted if app quits.

—Jens

Brendan Duddridge

unread,
Dec 3, 2015, 1:54:38 PM12/3/15
to Couchbase Mobile
I believe that you can enable auto-vacuum on SQLite, but I'm not sure if Couchbase Lite takes advantage of that. I know it does more than just vacuums the database. It also purges unreferenced attachments.

Brendan

Jens Alfke

unread,
Dec 3, 2015, 5:04:19 PM12/3/15
to mobile-c...@googlegroups.com

On Dec 3, 2015, at 10:54 AM, Brendan Duddridge <bren...@gmail.com> wrote:

I believe that you can enable auto-vacuum on SQLite, but I'm not sure if Couchbase Lite takes advantage of that. I know it does more than just vacuums the database. It also purges unreferenced attachments.

And deletes obsolete revisions. Vacuum is only a small part of what compaction does.

—Jens
Reply all
Reply to author
Forward
0 new messages