Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best Practices for Safely Using db.getRange #311

Open
damartripamungkas opened this issue Nov 1, 2024 · 1 comment
Open

Best Practices for Safely Using db.getRange #311

damartripamungkas opened this issue Nov 1, 2024 · 1 comment

Comments

@damartripamungkas
Copy link

Hello! Are there any specific guidelines for retrieving a large dataset—such as 5 million records—using getRange? I am already utilizing the "start" and "end" options, but I need advice on other optional parameters to ensure safe and efficient data handling. Any guidance would be appreciated!

@kriszyp
Copy link
Owner

kriszyp commented Nov 11, 2024

getRange should be quite efficient by default, as it will retrieve records on-demand for each iteration (doesn't hold the 5 million records in memory). However, if the query will continue for a long period of time and there are writes taking place and you aren't concerned about viewing an isolated snapshot of the data, you may want to consider disabling the snapshot flag (snapshot: false). This allows the read transaction to be continuously reset during iteration and avoids the cost of a long-lived read transactions (which causes database growth since it prevents in use old pages from being reclaimed/reused).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants