Log time spent in database (and some other minor performance debugging tweaks)