bug-fix: exempt deferred entries from prune

- do not prune test_entry daughter records that have
  an open deferral status
- perf improvement: skip query sections when tables are empty
- style fixes