infinum / android_dbinspector

Android library for viewing, editing and sharing in app databases.
Apache License 2.0
951 stars 91 forks source link

Using LIMIT OFFSET for paging cursor results #100

Closed chauhan-abhi closed 2 years ago

chauhan-abhi commented 2 years ago

:warning: Please describe your feature request

Is it like we are always fetching all records and then moving the cursor to our page limit and offset in the library.. Why are we not fetching only that many records using LIMIT and OFFSET?

:bulb: Describe the solution you'd like

:bar_chart: Describe alternatives you've considered

:page_facing_up: Additional context

:raising_hand: Do you want to develop this feature yourself?

bojankoma commented 2 years ago

@chauhan-abhi Hi, thank you for opening this issue and asking a very tricky question. :) In short, a cursor implementation has been chosen over offset pagination in order to optimize for large data sets. I can see that the logger showing SELECT * messages in console has been very misleading, so I will remove it in following release. Furthermore, this cursor implementation just creates a pointer to exact position and reads N fields from it, in comparison with offset pagination where you actually read rows and then truncate the output.

For more details about different pagination approaches, you can go here on this excellent Slack blog post.

Nevertheless, if you think a different approach would be a better one, a PR is most welcome and we can discuss it further.