bug #4239 Missing LIMIT clause for some queries

Signed-off-by: Marc Delisle <marc@infomarc.info>