Small change to oracle paging code to trigger stopkey optimization #160

Merged
merged 1 commit into from Jan 31, 2013

Projects

None yet

2 participants

@t0m
t0m commented Jan 31, 2013

I previously added a comment on issue 99 about a quick tweak to the paging code and I didn't want it to go to waste. Changing the raw_rnum_ predicate from:

WHERE raw_rnum_ BETWEEN :low and :high

to: WHERE raw_rnum_ >= :low and rownum <= :limit

allows the optimizer to use the count stopkey optimization and return the same results noticeably quicker.

Here's the execution plan for my DB with the current code:
no-stopkey

And with the changes:
stopkey

I've had this change running for almost a month in a few of my apps on 11G as well as some test projects on XE and everything seems cool, maybe someone else could give it a try and see if they get the same results?

@rafaelfranca
Member

Seems good. Thank you

@rafaelfranca rafaelfranca merged commit d8005bc into rails:master Jan 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment