Skip to content

Commit

Permalink
feat: add partial index on client_applications annouced FALSE (#6166)
Browse files Browse the repository at this point in the history
We have customers with tens or hundreds of thousands of applications,
and we have a scheduler running that sets application fields to
`announced` as true. However, every time it runs, it queries the entire
table, which is slow and causes database connection acquisition issues.
To make it faster, we added a partial index to the table.
  • Loading branch information
sjaanus authored Feb 8, 2024
1 parent c43d7c0 commit bc7d4b8
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

exports.up = function(db, cb) {
db.runSql(
`
CREATE INDEX IF NOT EXISTS idx_client_applications_announced_false ON client_applications (announced)
WHERE announced = FALSE;
`,
cb,
);
};

exports.down = function(db, cb) {
db.runSql(`
DROP INDEX IF EXISTS idx_client_applications_announced_false;
`, cb);
};

0 comments on commit bc7d4b8

Please sign in to comment.