move flushDatabase to IO service worker / native sql plugin

writing DB to filesystem is one of the biggest remaining performance bottlenecks.

DB writes can be handled by a service worker in order to prevent the UI from blocking.