Move the database thread to async task and impose a work limit