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

Fix inefficient queries on message expiration #93

Open
jmcarp opened this issue Nov 10, 2016 · 1 comment
Open

Fix inefficient queries on message expiration #93

jmcarp opened this issue Nov 10, 2016 · 1 comment

Comments

@jmcarp
Copy link
Contributor

jmcarp commented Nov 10, 2016

Currently, the message expiration task loads all messages into memory and issues a separate delete for each expired message. We should use a single delete query instead--something like

delete from messages where created_at + interval '1 hour' * hours > now()

That query won't work for all sql flavors. One option here would be to restrict to postgres. If that's a problem, then we could store the expiration time in the messages table instead of the duration to get a portable query like

delete from messages where expires_at > now()

WDYT?

@amoose
Copy link
Member

amoose commented Dec 9, 2016

👍
I don't see an issue with restricting to postgres in order to improve overall performance.

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

No branches or pull requests

3 participants