summaryrefslogtreecommitdiff
path: root/util/sql
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-10-12 20:58:02 +0200
committerYorhel <git@yorhel.nl>2015-10-12 21:17:48 +0200
commit61251790bd1da10eebee3c56a70a9711e7680ce8 (patch)
treeccf47fd384b54cf4d5c9bc378c556fc3aa3e6535 /util/sql
parent1a6dd0160a75bc83390912dfb2635cd5664ce9ee (diff)
Notifications: Allow max 500 notifies per user + add SQL index on uid
Turns out that fetching whether or not you have unread notifications (done on every pageview if you're logged in) was pretty slow. The index speeds up both that query and the "my notifications" view. The extra purge for old notifications for users with more than 500 notifications ensures that the index stays effective for the unread notifications count. Otherwise it'll have to read half of the notifications table anyway to check the 'unread' filter.
Diffstat (limited to 'util/sql')
-rw-r--r--util/sql/tableattrs.sql1
1 files changed, 1 insertions, 0 deletions
diff --git a/util/sql/tableattrs.sql b/util/sql/tableattrs.sql
index 1e812f01..4028e98e 100644
--- a/util/sql/tableattrs.sql
+++ b/util/sql/tableattrs.sql
@@ -77,6 +77,7 @@ ALTER TABLE wlists ADD CONSTRAINT wlists_vid_fkey FOR
CREATE INDEX affiliate_links_rid ON affiliate_links (rid) WHERE NOT hidden;
+CREATE INDEX notifications_uid ON notifications (uid);
CREATE INDEX releases_producers_rid ON releases_producers (rid);
CREATE INDEX releases_vn_vid ON releases_vn (vid);
CREATE INDEX tags_vn_date ON tags_vn (date);