Skip to content

Commit f303962

Browse files
committed
fix(database): update container name query to use exact match
- Modified the SQL queries in GetLastNContainerMetrics and GetAllMetricsContainer functions to use an exact match for container names instead of a LIKE clause, improving query accuracy and performance.
1 parent edc8efe commit f303962

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

apps/monitoring/database/containers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (db *DB) GetLastNContainerMetrics(containerName string, limit int) ([]Conta
5858
WITH recent_metrics AS (
5959
SELECT metrics_json
6060
FROM container_metrics
61-
WHERE container_name LIKE ? || '%'
61+
WHERE container_name = ?
6262
ORDER BY timestamp DESC
6363
LIMIT ?
6464
)
@@ -98,7 +98,7 @@ func (db *DB) GetAllMetricsContainer(containerName string) ([]ContainerMetric, e
9898
WITH recent_metrics AS (
9999
SELECT metrics_json
100100
FROM container_metrics
101-
WHERE container_name LIKE ? || '%'
101+
WHERE container_name = ?
102102
ORDER BY timestamp DESC
103103
)
104104
SELECT metrics_json FROM recent_metrics ORDER BY json_extract(metrics_json, '$.timestamp') ASC

0 commit comments

Comments
 (0)