mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
refactor: optimize applications overview (#6548)
There was no need to join the entire metrics table, as it is a huge table. We only needed all combinations of app_name, environment, and feature_name. The new query retrieves all this data, which will then be joined into the main query.
This commit is contained in:
parent
513d60c14d
commit
ba53bd7bf9
@ -292,6 +292,13 @@ export default class ClientApplicationsStore
|
||||
appName: string,
|
||||
): Promise<IApplicationOverview> {
|
||||
const query = this.db
|
||||
.with('metrics', (qb) => {
|
||||
qb.distinct(
|
||||
'cme.app_name',
|
||||
'cme.environment',
|
||||
'cme.feature_name',
|
||||
).from('client_metrics_env as cme');
|
||||
})
|
||||
.select([
|
||||
'f.project',
|
||||
'cme.environment',
|
||||
@ -302,7 +309,7 @@ export default class ClientApplicationsStore
|
||||
'a.strategies',
|
||||
])
|
||||
.from({ a: 'client_applications' })
|
||||
.leftJoin('client_metrics_env as cme', 'cme.app_name', 'a.app_name')
|
||||
.leftJoin('metrics as cme', 'cme.app_name', 'a.app_name')
|
||||
.leftJoin('features as f', 'cme.feature_name', 'f.name')
|
||||
.leftJoin('client_instances as ci', function () {
|
||||
this.on('ci.app_name', '=', 'cme.app_name').andOn(
|
||||
|
Loading…
Reference in New Issue
Block a user