Files
grafana/pkg/storage/unified/resource/data/sqlkv_batch_get.sql
T
Renato Costa 19f6dbe1bb unified-storage: add BatchGet support to the sqlkv implementation (#115517)
* unified-storage: add `BatchGet` support to the sqlkv implementation

* address comments

* fix linting
2025-12-18 11:21:36 -05:00

13 lines
466 B
SQL

SELECT r.{{ .Ident "key_path" }}, r.{{ .Ident "value" }}
FROM (
{{ range $id, $key_path := .KeyPaths }}
{{ if eq $id 0 }}
SELECT {{ $.Arg $id }} AS idx, {{ $.Arg $key_path }} AS key_path
{{ else }}
UNION ALL SELECT {{ $.Arg $id }}, {{ $.Arg $key_path }}
{{ end }}
{{ end }}
) AS requested_keys
INNER JOIN {{ .TableName }} r ON r.{{ .Ident "key_path" }} = requested_keys.{{ .Ident "key_path" }}
ORDER BY requested_keys.{{ .Ident "idx" }};