Our notifications table is large, and we run frequent SELECT queries on it, but postgres does not automatically index foreign key columns, so WHERE clauses on these columns will require a full table scan, which results in inefficient db queries. This PR adds indexes to the foreign keys in the notifications table to speed up our queries.
Note that site_id is only indexed with user_id, since we never filter by site_id alone.
Deploy Notes
~Run migration on staging and master before merge~ DONE
Problem
Our notifications table is large, and we run frequent SELECT queries on it, but postgres does not automatically index foreign key columns, so WHERE clauses on these columns will require a full table scan, which results in inefficient db queries. This PR adds indexes to the foreign keys in the notifications table to speed up our queries.
Note that
site_id
is only indexed withuser_id
, since we never filter bysite_id
alone.Deploy Notes