Use built-in maximum vs raw sql.
Use built-in maximum vs raw sql.

ActiveRecord's generated sql is:

SELECT MAX("pages"."end_offset") AS max_id FROM "pages" WHERE
"pages"."document_id" = $1  [["document_id", 368941146]]

roberttdev/dactyl4,gunjanmodi/documentcloud,Teino1978-Corp/Teino1978-Corp-documentcloud,documentcloud/documentcloud,dannguyen/documentcloud,monofox/documentcloud,ivarvong/documentcloud,dannguyen/documentcloud,ivarvong/documentcloud,documentcloud/documentcloud,gunjanmodi/documentcloud,ivarvong/documentcloud,ivarvong/documentcloud,gunjanmodi/documentcloud,moodpo/documentcloud,documentcloud/documentcloud,monofox/documentcloud,Teino1978-Corp/Teino1978-Corp-documentcloud,moodpo/documentcloud,gunjanmodi/documentcloud,moodpo/documentcloud,monofox/documentcloud,moodpo/documentcloud,Teino1978-Corp/Teino1978-Corp-documentcloud,roberttdev/dactyl4,roberttdev/dactyl4,roberttdev/dactyl4,monofox/documentcloud,dannguyen/documentcloud,Teino1978-Corp/Teino1978-Corp-documentcloud,documentcloud/documentcloud,dannguyen/documentcloud