Skip to content

Commit

Permalink
added index to events
Browse files Browse the repository at this point in the history
  • Loading branch information
fomalhautb committed Dec 20, 2024
1 parent c28a80d commit 63a3777
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE INDEX idx_event_userid ON "Event" ((data->>'userId'));
CREATE INDEX idx_event_projectid ON "Event" ((data->>'projectId'));

2 comments on commit 63a3777

@N2D4
Copy link
Contributor

@N2D4 N2D4 commented on 63a3777 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fomalhautb shouldn't this already be part of the GIN index?

@fomalhautb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently not. GIN index only supports @> operator but not ->>. I used EXPLAIN and found that some event queries are linear searches, so I added the index and fixed the problem.

Image

Another way to solve this is to rewrite our query with @> instead of adding a new index.

Please sign in to comment.