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

Added organization_id index to notifications #3155

Merged

Conversation

lightalloy
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Optimization

Description

Added organization_id index to the notifications table.

Explaining query without an index:

Notification.where("organization_id = 3 and read = false").select("count(*)").explain
------------------------------------------------------------------------
 Aggregate  (cost=780.32..780.33 rows=1 width=8)
   ->  Seq Scan on notifications  (cost=0.00..775.94 rows=1753 width=0)
         Filter: ((NOT read) AND (organization_id = 3))
(3 rows)

With the provided index:

Notification.where("organization_id = 3 and read = false").select("count(*)").explain
-----------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=338.36..338.37 rows=1 width=8)
   ->  Index Scan using index_notifications_on_organization_id on notifications  (cost=0.28..333.98 rows=1753 width=0)
         Index Cond: (organization_id = 3)
         Filter: (NOT read)
(4 rows)

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jun 14, 2019
@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jun 14, 2019
@benhalpern benhalpern merged commit 8605f29 into forem:master Jun 14, 2019
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jun 14, 2019
@lightalloy lightalloy deleted the add-notifications-organization_id-index branch June 14, 2019 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants