-
Story
-
Resolution: Unresolved
-
Normal
-
None
-
Product / Portfolio Work
-
False
-
-
False
-
None
-
Unset
-
None
-
-
-
Currently, when we generate a drawer notification, we also create a record in db for each user of the targeted org.
We do that to reflect id a particular user marked a notification as read or not.
Because of that, the underlining table and indexes are huge.
Because we create a record for each user of the org, most of those records may be useless regarding how many users may connect to HCC and open the drawer panel.
We should consider to refactor it to add only one record per drawer notification with the list of recipients and the list of users (jsonb) how marked those as read.
To index those data, we could use a `btree gin` that could look like:
CREATE INDEX idx_org_recipients ON drawer_notification USING GIN (org_id, recipients);
Then the search query could look like:
SELECT * FROM drawer_notification WHERE org_id = 'org123' AND recipients @> '["bob"]';