Fixes issue 216.

Use query limit/offset on query instead of query result.