Puzzled about SQL paging implementation

40 views
Skip to first unread message

Adam Cameron

unread,
Apr 29, 2022, 5:07:35 PM4/29/22
to CFWheels
Hi.
I was rather intrigued today when it was brought to my attn than this statement:

tests = model("Test").findAll(select="value", page=10, perPage=100, order="id")

Results in this SQL:

SELECT test.value FROM test WHERE ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) OR ( test.id = ? ) ORDER BY test.id ASC

As opposed to what one might expect for MySQL, which would be:

SELECT value
FROM test
ORDER BY id
LIMIT 100 offset 900

It seems to be like this on 1.4 (where we spotted it) and 2.2 alike.

This strikes me as a fairly unorthodox way of going about paging, and - IANADBA - doesn't look like it would be very efficient.

I've never seen anything like this.

What am I missing?

Cheers.

-- 
Adam
Reply all
Reply to author
Forward
0 new messages