1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

feat: add index on events for faster revision id (#6170)

On all pods and instances, we run the same revision update query every
second. It is relatively fast when the application has started. This is
the single most ran query in unleash.
Benchmarks:

1. Running pod with existing revisionID:
  - old 5.5ms
  - new 0.028ms

2. New pod without existing revisionID
 - old 9.329ms
 - new 0.033ms



This query is getting optimized


7e66a79f9f/src/lib/features/events/event-store.ts (L161)
This commit is contained in:
Jaanus Sellin 2024-02-08 14:11:58 +02:00 committed by GitHub
parent 7e66a79f9f
commit ecc200bf8a
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, cb) {
db.runSql(
`
CREATE INDEX IF NOT EXISTS idx_events_feature_type_id ON events (id)
WHERE feature_name IS NOT NULL
OR type IN ('segment-updated', 'feature_import', 'features-imported');
`,
cb,
);
};
exports.down = function(db, cb) {
db.runSql(`
DROP INDEX IF EXISTS idx_events_feature_type_id;
`, cb);
};