malthe/pq — pull request #1 by malthe (2014-06-05 15:15:55+00:00)
Title: First select <number-of-database-connections> rows, then acquire lock

This seems to solve a concurrency issue where every so often the database
will acquire a lock on thousands of row because the limit is applied only
afterwards.