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

Indexes #24

Open
minsau opened this issue Feb 18, 2023 · 1 comment
Open

Indexes #24

minsau opened this issue Feb 18, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@minsau
Copy link

minsau commented Feb 18, 2023

Hello! I succesfully integrate the library is great! But When it was used in a semi-prod environment, it elevates the cpu usage, and it was because when you look for the notifications use channel and payload as filters, those fields has no indexes due to that the queries are realy low.

So, adding a multi-field index, do the trick for us.
You can considere add it as main part

@PaulGilmartin
Copy link
Owner

@minsau that's a good suggestion and I can see how that could make a great improvement to the performance of the query

            Notification.objects.select_for_update(
                skip_locked=True).filter(
                channel=self.notification.channel,
                payload=self.notification.payload,
            )

I will try to add that in the next version of this library. Perhaps however the index should be optional, since adding an index on an already large/active table can sometimes be tricky in production.

Feel free to share the code you added or submit a pull request with the proposed change, otherwise I will look at it whenever I have time :)

@PaulGilmartin PaulGilmartin added the enhancement New feature or request label Feb 19, 2023
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