refs #6933 use unbuffered query to reduce mem usage; leave most of original code in place for reference