-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Checklist
- This feature will maintain backward compatibility with the current sdk. If not, please raise a refactor issue first.
Background
This feature request is related to a performance enhancement in the CLI when displaying EnvInstance list information. Currently, when retrieving the list of EnvInstances, only basic fields are returned. To display additional information such as environment name, environment version, IP, and status, the CLI must make additional individual queries using the env name and instance id, resulting in multiple round-trips and degraded performance.
We aim to optimize this workflow by including the necessary fields directly in the EnvInstance list response, eliminating the need for subsequent queries and significantly improving response time and user experience.
Potential Solution
Modify the /api/env-instances/:id/list (or equivalent) list endpoint to include the following fields in each returned EnvInstance object:
env_name(string)env_version(string)ip(string)status(string)
These fields should be populated during the initial query (via database join or service aggregation) rather than fetched per-instance. This change reduces the number of backend calls from O(n) to O(1) for listing operations.
No breaking changes are expected on the SDK side, as this is a backward-compatible addition of fields to an existing response payload. Clients that do not use the new fields will continue to function normally.
Additional Information
- This optimization is particularly impactful in environments with a large number of instances, where the current N+1 query pattern leads to noticeable latency.
- Similar optimizations are commonly implemented in APIs following the "projection" or "denormalization for read efficiency" pattern (e.g., Kubernetes API embedding common status fields in list responses).
- Consider adding appropriate database indexing on joined fields (e.g.,
env_idinEnvInstance) to support efficient lookups.