(#1926) - More efficient changes() for idb/websql

This moves more of the limit/doc_ids filtering logic
up-front, so that we don't have to read the entire
changes stream into memory and then filter at the end.