1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: add index on events created at (#7836)

After adding an index, the time for the new event search on 100k events
decreased from 5000ms to 4ms. This improvement is due to the query using
an index scan instead of a sequence scan.
This commit is contained in:
Jaanus Sellin 2024-08-12 12:46:50 +03:00 committed by GitHub
parent 99f878d725
commit ea057d1777
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,19 @@
'use strict';
exports.up = function (db, callback) {
db.runSql(
`
CREATE INDEX idx_events_created_at_desc ON events (created_at DESC);
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
DROP INDEX IF EXISTS idx_events_created_at_desc;
`,
callback,
);
};