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

Count is eating up all the memory #86

Closed
artvel opened this issue Apr 24, 2022 · 3 comments
Closed

Count is eating up all the memory #86

artvel opened this issue Apr 24, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@artvel
Copy link

artvel commented Apr 24, 2022

Hi guys

When using Count in a DB with a huge amount of entries the memory is being eaten up.
And it is being freed right after Count.

Cheers,
artvel

@timshannon timshannon self-assigned this Apr 26, 2022
@timshannon
Copy link
Owner

I'm using an iterator, so the complete dataset shouldn't be held in memory by badgerhold, however badger itself may be caching data in memory, which is a common tactic used by databases. Badger in general tends to use a lot more memory compared to BoltDB.

However, I believe I can make this count more efficient by using a key only iterator. I'll need to do some research.

Thanks for reporting.

@timshannon timshannon added the enhancement New feature or request label Apr 26, 2022
@timshannon
Copy link
Owner

Yeah, doing a key only iterator won't work, because the values are needed in order to filter by the query criteria.

I could disable pre-fetching values, but that would come at the cost of performance. The root of the issue is the fact that badger has decided (like most databases) to pay for more performance with memory usage.

If you want more control over your memory usage you can tweak the options passed into badger: https://dgraph.io/docs/badger/get-started/#memory-usage

@artvel
Copy link
Author

artvel commented Apr 27, 2022

Thanks, that sounds reasonable. I'll look into that.

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

No branches or pull requests

2 participants