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

Should we consider db indexing commonly queried fields? (memory optimization idea) #29

Open
KalobTaulien opened this issue May 27, 2021 · 1 comment

Comments

@KalobTaulien
Copy link
Collaborator

I've noticed that wagtail-ab-testing is using about 60mb of memory locally and it scales up to about 150mb on some servers. For servers with lower memory, it'd be great to get this number down as much as possible.

https://github.com/torchbox/wagtail-ab-testing/blob/1ed69c764ed92e7495676ae34e1a5d6422977401/wagtail_ab_testing/models.py#L81

https://github.com/torchbox/wagtail-ab-testing/blob/1ed69c764ed92e7495676ae34e1a5d6422977401/wagtail_ab_testing/models.py#L77

If these are being queried often and there are a lot of tests, would we benefit from adding db_index=True to these fields?

@Stormheg
Copy link
Member

I don't think indexing the mentioned fields is going to improve memory usage. Indexing is done with the intent to improve query performance on the database. I don't think this is going to improve the memory usage of your Django application.

I don't have a production setup of wagtail-ab-testing myself, meaning I can't measure as to what the peak memory usage of wagtail-ab-testing is.

If there is anyone interested in doing some measuring with a fairly large database, I'd welcome a more detailed report.

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