add fetchAs type support. The options is: array, object or iterator
Optimze db query and add iterator option support