Remove the search result limitation. Create an index for the peer file table. Don't clear bindings after inserting each entry. Perform large queries in multiple stages to prevent hitting CursorWindow limits. Use a deferred transaction when inserting database entries.