Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rework application overview db query #8518

Merged
merged 2 commits into from
Oct 23, 2024
Merged

feat: rework application overview db query #8518

merged 2 commits into from
Oct 23, 2024

Conversation

sjaanus
Copy link
Contributor

@sjaanus sjaanus commented Oct 23, 2024

Previously we were returning all instance names from database, but now we count them in database.

Copy link

vercel bot commented Oct 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 0:58am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Oct 23, 2024 0:58am

Copy link
Contributor

github-actions bot commented Oct 23, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@@ -313,29 +313,40 @@ export default class ClientApplicationsStore
),
])
.from('client_metrics_env as cme')
.where('cme.app_name', appName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra where clause to reduce query scope

qb.select([
'ci.app_name',
'ci.environment',
this.db.raw(
Copy link
Contributor Author

@sjaanus sjaanus Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we count in database level, instead of joining and returning all.

this.db.raw(
'COUNT(DISTINCT ci.instance_id) as unique_instance_count',
),
this.db.raw(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also count these in database.

this.db.raw(
'ARRAY_AGG(DISTINCT ci.sdk_version) as sdk_versions',
),
this.db.raw('MAX(ci.last_seen) as latest_last_seen'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also last seen, max will be taken, instead of doing it in memory.

@@ -397,25 +405,14 @@ export default class ClientApplicationsStore
};
acc.push(env);
} else {
if (instance_id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of all of this logic done in memory

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, can we validate this in sandbox before rolling out? Maybe checking prometheus metrics before and after the change or just checking in Grafana

.orderBy('m.environment', 'asc');
console.log(query.toQuery());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(query.toQuery());

@sjaanus sjaanus merged commit 9839b77 into main Oct 23, 2024
11 checks passed
@sjaanus sjaanus deleted the imp-perf branch October 23, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants