PostgreSql utils: fix block query

There was no whitespace around the AND operators and before LIMIT, causing the
query to fail.